TP-20241126-znuny-view-customer_company #129
@ -5,10 +5,11 @@
|
|||||||
--changeset timotheus.pokorra:hs-global-integration-znuny endDelimiter:--//
|
--changeset timotheus.pokorra:hs-global-integration-znuny endDelimiter:--//
|
||||||
-- TODO.impl: also select column debitorNumber and do not filter anymore for '00'
|
-- TODO.impl: also select column debitorNumber and do not filter anymore for '00'
|
||||||
CREATE OR REPLACE VIEW hs_integration.contact AS
|
CREATE OR REPLACE VIEW hs_integration.contact AS
|
||||||
SELECT DISTINCT ON (uuid)
|
SELECT DISTINCT ON (contact_uuid)
|
||||||
partner.partnernumber as partnernumber,
|
partner.partnernumber as partnernumber,
|
||||||
debitor.defaultprefix as defaultprefix,
|
debitor.defaultprefix as defaultprefix,
|
||||||
c.uuid as uuid,
|
partner.uuid as partner_uuid,
|
||||||
|
c.uuid as contact_uuid,
|
||||||
(CASE WHEN per.salutation <> '' THEN per.salutation ELSE NULL END) as salutation,
|
(CASE WHEN per.salutation <> '' THEN per.salutation ELSE NULL END) as salutation,
|
||||||
(CASE WHEN per.givenname <> '' THEN per.givenname ELSE NULL END) as givenname,
|
(CASE WHEN per.givenname <> '' THEN per.givenname ELSE NULL END) as givenname,
|
||||||
(CASE WHEN per.familyname <> '' THEN per.familyname ELSE NULL END) as familyname,
|
(CASE WHEN per.familyname <> '' THEN per.familyname ELSE NULL END) as familyname,
|
||||||
@ -38,10 +39,11 @@ CREATE OR REPLACE VIEW hs_integration.contact AS
|
|||||||
JOIN hs_office.contact AS c ON c.uuid = pRel.contactuuid
|
JOIN hs_office.contact AS c ON c.uuid = pRel.contactuuid
|
||||||
JOIN hs_office.person AS per ON per.uuid = pRel.holderuuid
|
JOIN hs_office.person AS per ON per.uuid = pRel.holderuuid
|
||||||
UNION
|
UNION
|
||||||
SELECT DISTINCT ON (uuid)
|
SELECT DISTINCT ON (contact_uuid)
|
||||||
partner.partnernumber as partnernumber,
|
partner.partnernumber as partnernumber,
|
||||||
debitor.defaultprefix as defaultprefix,
|
debitor.defaultprefix as defaultprefix,
|
||||||
c.uuid as uuid,
|
partner.uuid as partner_uuid,
|
||||||
|
c.uuid as contact_uuid,
|
||||||
(CASE WHEN per.salutation <> '' THEN per.salutation ELSE NULL END) as salutation,
|
(CASE WHEN per.salutation <> '' THEN per.salutation ELSE NULL END) as salutation,
|
||||||
(CASE WHEN per.givenname <> '' THEN per.givenname ELSE NULL END) as givenname,
|
(CASE WHEN per.givenname <> '' THEN per.givenname ELSE NULL END) as givenname,
|
||||||
(CASE WHEN per.familyname <> '' THEN per.familyname ELSE NULL END) as familyname,
|
(CASE WHEN per.familyname <> '' THEN per.familyname ELSE NULL END) as familyname,
|
||||||
@ -73,7 +75,7 @@ CREATE OR REPLACE VIEW hs_integration.contact AS
|
|||||||
JOIN hs_office.person AS per ON per.uuid = relation.holderuuid;
|
JOIN hs_office.person AS per ON per.uuid = relation.holderuuid;
|
||||||
|
|
||||||
CREATE OR REPLACE VIEW hs_integration.ticket_customer_user AS
|
CREATE OR REPLACE VIEW hs_integration.ticket_customer_user AS
|
||||||
SELECT c.uuid,
|
SELECT c.contact_uuid,
|
||||||
max(c.partnernumber)::text as number,
|
max(c.partnernumber)::text as number,
|
||||||
max(c.defaultprefix) as code,
|
max(c.defaultprefix) as code,
|
||||||
max(c.email) as login,
|
max(c.email) as login,
|
||||||
@ -96,7 +98,27 @@ CREATE OR REPLACE VIEW hs_integration.ticket_customer_user AS
|
|||||||
string_agg(CASE WHEN relation.mark IS NULL THEN relation.type::text ELSE CONCAT(relation.type::text, ':', relation.mark::text) END, '/'::text) AS comment,
|
string_agg(CASE WHEN relation.mark IS NULL THEN relation.type::text ELSE CONCAT(relation.type::text, ':', relation.mark::text) END, '/'::text) AS comment,
|
||||||
1 AS valid
|
1 AS valid
|
||||||
FROM hs_integration.contact AS c
|
FROM hs_integration.contact AS c
|
||||||
JOIN hs_office.relation AS relation ON c.uuid = relation.contactuuid
|
JOIN hs_office.relation AS relation ON c.contact_uuid = relation.contactuuid
|
||||||
WHERE (c.defaultprefix != 'hsh' OR (c.partnernumber = 10000 AND c.email = 'hostmaster@hostsharing.net'))
|
WHERE (c.defaultprefix != 'hsh' OR (c.partnernumber = 10000 AND c.email = 'hostmaster@hostsharing.net'))
|
||||||
GROUP BY c.uuid;
|
GROUP BY c.contact_uuid;
|
||||||
|
|
||||||
|
CREATE OR REPLACE VIEW hs_integration.ticket_customer_company AS
|
||||||
|
SELECT
|
||||||
|
partner.partnernumber::text as number,
|
||||||
|
debitor.defaultprefix as code,
|
||||||
|
concat_ws('/'::text, to_char(lower(membership.validity), 'YYYY-MM-DD'::text), to_char(upper(membership.validity) - INTERVAL '1 days', 'YYYY-MM-DD'::text)) AS comment,
|
||||||
|
1 AS valid
|
||||||
|
FROM hs_office.partner AS partner
|
||||||
|
JOIN hs_office.relation AS pRel
|
||||||
|
ON pRel.type = 'PARTNER'
|
||||||
|
AND pRel.uuid = partner.partnerRelUuid
|
||||||
|
JOIN hs_office.relation AS dRel
|
||||||
|
ON dRel.type = 'DEBITOR'
|
||||||
|
AND dRel.anchorUuid = pRel.holderUuid
|
||||||
|
JOIN hs_office.debitor AS debitor
|
||||||
|
ON debitor.debitorreluuid = dRel.uuid
|
||||||
|
AND debitor.debitornumbersuffix = '00'
|
||||||
|
LEFT OUTER JOIN hs_office.membership AS membership ON membership.partneruuid = partner.uuid
|
||||||
|
ORDER BY number;
|
||||||
|
|
||||||
--//
|
--//
|
@ -884,15 +884,15 @@ public abstract class BaseOfficeDataImport extends CsvDataImport {
|
|||||||
final var legacyId = entry.getKey();
|
final var legacyId = entry.getKey();
|
||||||
final var assetTransaction = entry.getValue();
|
final var assetTransaction = entry.getValue();
|
||||||
if (assetTransaction.getTransactionType() == HsOfficeCoopAssetsTransactionType.REVERSAL) {
|
if (assetTransaction.getTransactionType() == HsOfficeCoopAssetsTransactionType.REVERSAL) {
|
||||||
connectToRelatedRevertedAssetTx(assetTransaction);
|
connectToRelatedRevertedAssetTx(legacyId, assetTransaction);
|
||||||
}
|
}
|
||||||
if (assetTransaction.getTransactionType() == HsOfficeCoopAssetsTransactionType.TRANSFER) {
|
if (assetTransaction.getTransactionType() == HsOfficeCoopAssetsTransactionType.TRANSFER) {
|
||||||
connectToRelatedAdoptionAssetTx(assetTransaction);
|
connectToRelatedAdoptionAssetTx(legacyId, assetTransaction);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void connectToRelatedRevertedAssetTx(final HsOfficeCoopAssetsTransactionEntity assetTransaction) {
|
private static void connectToRelatedRevertedAssetTx(final int legacyId, final HsOfficeCoopAssetsTransactionEntity assetTransaction) {
|
||||||
final var negativeValue = assetTransaction.getAssetValue().negate();
|
final var negativeValue = assetTransaction.getAssetValue().negate();
|
||||||
final var revertedAssetTx = coopAssets.values().stream().filter(a ->
|
final var revertedAssetTx = coopAssets.values().stream().filter(a ->
|
||||||
a.getTransactionType() != HsOfficeCoopAssetsTransactionType.REVERSAL &&
|
a.getTransactionType() != HsOfficeCoopAssetsTransactionType.REVERSAL &&
|
||||||
@ -905,10 +905,11 @@ public abstract class BaseOfficeDataImport extends CsvDataImport {
|
|||||||
//revertedAssetTx.setAssetReversalTx(assetTransaction);
|
//revertedAssetTx.setAssetReversalTx(assetTransaction);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void connectToRelatedAdoptionAssetTx(final HsOfficeCoopAssetsTransactionEntity assetTransaction) {
|
private static void connectToRelatedAdoptionAssetTx(final int legacyId, final HsOfficeCoopAssetsTransactionEntity assetTransaction) {
|
||||||
final var negativeValue = assetTransaction.getAssetValue().negate();
|
final var negativeValue = assetTransaction.getAssetValue().negate();
|
||||||
final var adoptionAssetTx = coopAssets.values().stream().filter(a ->
|
final var adoptionAssetTx = coopAssets.values().stream().filter(a ->
|
||||||
a.getTransactionType() == HsOfficeCoopAssetsTransactionType.ADOPTION &&
|
a.getTransactionType() == HsOfficeCoopAssetsTransactionType.ADOPTION &&
|
||||||
|
(!a.getValueDate().equals(LocalDate.of( 2014 , 12 , 31)) || a.getComment().contains(Integer.toString(assetTransaction.getMembership().getMemberNumber()/100))) &&
|
||||||
a.getMembership() != assetTransaction.getMembership() &&
|
a.getMembership() != assetTransaction.getMembership() &&
|
||||||
a.getValueDate().equals(assetTransaction.getValueDate()) &&
|
a.getValueDate().equals(assetTransaction.getValueDate()) &&
|
||||||
a.getAssetValue().equals(negativeValue))
|
a.getAssetValue().equals(negativeValue))
|
||||||
|
Loading…
Reference in New Issue
Block a user