From fa0990dd17a7eacd36034aa75f908e1ba26a9e6a Mon Sep 17 00:00:00 2001 From: Dmitry Kovyazin Date: Tue, 26 Nov 2024 12:56:34 +0500 Subject: [PATCH 1/7] feat(condo): DOMA-10747 added balanceUpdatedAt field --- apps/condo/domains/billing/gql.js | 2 +- .../AllResidentBillingReceiptsService.test.js | 8 ++++-- .../domains/billing/schema/BillingReceipt.js | 6 +++++ .../schema/RegisterBillingReceiptsService.js | 6 ----- .../schema/resolvers/receiptResolver.js | 8 ++++-- .../billing/utils/serverSchema/index.js | 22 ++++++++++------ apps/condo/schema.graphql | 26 +++++++++++++++++++ apps/condo/schema.ts | 26 +++++++++++++++++++ 8 files changed, 85 insertions(+), 19 deletions(-) diff --git a/apps/condo/domains/billing/gql.js b/apps/condo/domains/billing/gql.js index 427c374916d..9f451c00755 100644 --- a/apps/condo/domains/billing/gql.js +++ b/apps/condo/domains/billing/gql.js @@ -41,7 +41,7 @@ const BILLING_RECEIPT_SERVICE_TO_PAY_DETAILS_FIELDS = `toPayDetails { ${BILLING_ const BILLING_RECEIPT_SERVICE_FIELDS = `services { id name toPay ${BILLING_RECEIPT_SERVICE_TO_PAY_DETAILS_FIELDS} }` const BILLING_RECEIPT_RECIPIENT_FIELDS = 'recipient { name tin iec bic bankAccount }' const BILLING_RECEIPT_COMMON_FIELDS = `context ${BILLING_INTEGRATION_ORGANIZATION_CONTEXT_FIELDS} importId property { id address addressKey } account { id number unitType unitName fullName property { address } ownerType globalId isClosed } period toPay printableNumber toPayDetails { ${BILLING_RECEIPT_TO_PAY_DETAILS_FIELDS} } ${BILLING_RECEIPT_SERVICE_FIELDS} charge formula balance recalculation privilege penalty paid receiver { id tin iec bic bankAccount isApproved } ${BILLING_RECEIPT_RECIPIENT_FIELDS} ${COMMON_FIELDS} category ${BILLING_CATEGORY_FIELDS} invalidServicesError` -const BILLING_RECEIPT_FIELDS = `{ ${BILLING_RECEIPT_COMMON_FIELDS} file { id file { id filename originalFilename publicUrl mimetype } controlSum } acquiringIntegrationId acquiringHostUrl canGroupReceipts currencyCode }` +const BILLING_RECEIPT_FIELDS = `{ ${BILLING_RECEIPT_COMMON_FIELDS} file { id file { id filename originalFilename publicUrl mimetype } controlSum } acquiringIntegrationId acquiringHostUrl canGroupReceipts currencyCode balanceUpdatedAt }` const BILLING_RECEIPT_ADMIN_FIELDS = `{ ${BILLING_RECEIPT_COMMON_FIELDS} file { id sensitiveDataFile { id filename originalFilename publicUrl mimetype } publicDataFile { id filename originalFilename publicUrl mimetype } controlSum } isPayable }` const BillingReceipt = generateGqlQueries('BillingReceipt', BILLING_RECEIPT_FIELDS) diff --git a/apps/condo/domains/billing/schema/AllResidentBillingReceiptsService.test.js b/apps/condo/domains/billing/schema/AllResidentBillingReceiptsService.test.js index 8fa55edb6a3..f43b009019f 100644 --- a/apps/condo/domains/billing/schema/AllResidentBillingReceiptsService.test.js +++ b/apps/condo/domains/billing/schema/AllResidentBillingReceiptsService.test.js @@ -301,11 +301,16 @@ describe('AllResidentBillingReceiptsService', () => { const payAmount = '5000.00' const jsonReceipt = utils.createJSONReceipt({ importId, accountNumber, toPay: payAmount, toPayDetails: { charge: payAmount } }) const [[{ id: receiptId }]] = await utils.createReceipts([jsonReceipt]) + console.error('====== 1.') const resident = await utils.createResident() const [{ id: serviceConsumerId }] = await utils.createServiceConsumer(resident, accountNumber) await utils.payForReceipt(receiptId, serviceConsumerId) + console.error('====== 2.') + const [[{ id: updatedReceiptId }]] = await utils.createReceipts([{ ...jsonReceipt, toPay: '0.00', toPayDetails: { charge: payAmount, paid: payAmount } }]) expect(updatedReceiptId).toEqual(receiptId) + console.error('====== 3.') + const receiptsAfterPayment = await ResidentBillingReceipt.getAll(utils.clients.resident, { serviceConsumer: { resident: { id: resident.id } }, }) @@ -411,8 +416,7 @@ describe('AllResidentBillingReceiptsService', () => { expect(receiptAfterPayment.isPayable).toBeTruthy() }) - // TODO(dkovyazin): Add additional field on balance change to calculate new payments and display on mobile app - test.skip('paid field calculated when organization bank info changed', async () => { + test('paid field calculated when organization bank info changed', async () => { const accountNumber = faker.random.alphaNumeric(12) const total = '5000.00' const jsonReceipt = utils.createJSONReceipt({ accountNumber, toPay: total }) diff --git a/apps/condo/domains/billing/schema/BillingReceipt.js b/apps/condo/domains/billing/schema/BillingReceipt.js index ea18aa8b415..a41a4f50233 100644 --- a/apps/condo/domains/billing/schema/BillingReceipt.js +++ b/apps/condo/domains/billing/schema/BillingReceipt.js @@ -135,6 +135,12 @@ const BillingReceipt = new GQLListSchema('BillingReceipt', { access: readOnlyFieldAccess, }, + balanceUpdatedAt: { + type: 'DateTimeUtc', + kmigratorOptions: { db_index: true }, + isRequired: false, + }, + paid: { ...MONEY_AMOUNT_FIELD, schemaDoc: 'Amount of money that recipient already paid by current receipt. Example: "50.00", "-50.00"', diff --git a/apps/condo/domains/billing/schema/RegisterBillingReceiptsService.js b/apps/condo/domains/billing/schema/RegisterBillingReceiptsService.js index 0b527eb85c5..b0bdc3d0ead 100644 --- a/apps/condo/domains/billing/schema/RegisterBillingReceiptsService.js +++ b/apps/condo/domains/billing/schema/RegisterBillingReceiptsService.js @@ -98,12 +98,6 @@ const RegisterBillingReceiptsService = new GQLCustomSchema('RegisterBillingRecei schema: 'registerBillingReceipts(data: RegisterBillingReceiptsInput!): [BillingReceipt]', resolver: async (parent, args, context = {}) => { const { data: { context: billingContextInput, receipts: receiptsInput, dv, sender } } = args - // The flow description: - // 1. Normalize addresses - // 2. Collect data for BillingProblems - // 3. Create BillingRecipients - // 4. Auto-detect BillingCategory - // Input guard validations if (receiptsInput.length > RECEIPTS_LIMIT) { throw new GQLError(ERRORS.RECEIPTS_LIMIT_HIT, context) diff --git a/apps/condo/domains/billing/schema/resolvers/receiptResolver.js b/apps/condo/domains/billing/schema/resolvers/receiptResolver.js index 2bed0bcf791..0305c6c6456 100644 --- a/apps/condo/domains/billing/schema/resolvers/receiptResolver.js +++ b/apps/condo/domains/billing/schema/resolvers/receiptResolver.js @@ -50,8 +50,12 @@ class ReceiptResolver extends Resolver { ['category', 'account', 'property', 'receiver'] ) if (!isEmpty(updateInput)) { + if (updateInput.hasOwnProperty('toPay') || updateInput.hasOwnProperty('toPayDetails')) { + console.error('BALANCE UPDATE') + updateInput['balanceUpdatedAt'] = new Date().toISOString() + } try { - receiptIndex[index] = await BillingReceipt.update(this.context, receiptToUpdate.id, { ...updateInput, raw: receipt }) + receiptIndex[index] = await BillingReceipt.update(this.context, receiptToUpdate.id, { ...updateInput, raw: receipt }, 'id') } catch (error) { this.error(ERRORS.RECEIPT_SAVE_FAILED, index, error) } @@ -65,7 +69,7 @@ class ReceiptResolver extends Resolver { try { receiptIndex[index] = await BillingReceipt.create(this.context, this.buildCreateInput({ ...pick(receipt, RECEIPT_UPDATE_FIELDS), context: this.billingContext.id, raw: receipt, - }, ['category', 'account', 'property', 'receiver', 'context'])) + }, ['category', 'account', 'property', 'receiver', 'context']), 'id') } catch (error) { this.error(ERRORS.RECEIPT_SAVE_FAILED, index, error) } diff --git a/apps/condo/domains/billing/utils/serverSchema/index.js b/apps/condo/domains/billing/utils/serverSchema/index.js index 3c4af4c80d3..14b999ff659 100644 --- a/apps/condo/domains/billing/utils/serverSchema/index.js +++ b/apps/condo/domains/billing/utils/serverSchema/index.js @@ -67,14 +67,20 @@ const getPaymentsSum = async (receiptId) => { */ const getNewPaymentsSum = async (receiptId) => { const receipt = await getById('BillingReceipt', receiptId) - const payments = await find('Payment', { - AND: [ - { status_in: [PAYMENT_DONE_STATUS, PAYMENT_WITHDRAWN_STATUS] }, - { deletedAt: null }, - { receipt: { id: receiptId } }, - { OR: [ { transferDate_gte: new Date(receipt.updatedAt).toISOString() }, { transferDate: null } ] }, - ], - }) + const conditions = [ + { status_in: [PAYMENT_DONE_STATUS, PAYMENT_WITHDRAWN_STATUS] }, + { deletedAt: null }, + { receipt: { id: receiptId } }, + ] + if (receipt.balanceUpdatedAt) { + conditions.push({ + OR: [ + { transferDate: null }, + { transferDate_gte: new Date(receipt.balanceUpdatedAt).toISOString() }, + ], + }) + } + const payments = await find('Payment', { AND: conditions }) return payments.reduce((total, current) => (Big(total).plus(current.amount)), 0).toFixed(8).toString() } diff --git a/apps/condo/schema.graphql b/apps/condo/schema.graphql index d28d7a1d309..78cd07aa8fc 100644 --- a/apps/condo/schema.graphql +++ b/apps/condo/schema.graphql @@ -12526,6 +12526,7 @@ type BillingReceiptHistoryRecord { recalculation: String privilege: String penalty: String + balanceUpdatedAt: String paid: String toPayDetails: JSON services: JSON @@ -12680,6 +12681,14 @@ input BillingReceiptHistoryRecordWhereInput { penalty_gte: String penalty_in: [String] penalty_not_in: [String] + balanceUpdatedAt: String + balanceUpdatedAt_not: String + balanceUpdatedAt_lt: String + balanceUpdatedAt_lte: String + balanceUpdatedAt_gt: String + balanceUpdatedAt_gte: String + balanceUpdatedAt_in: [String] + balanceUpdatedAt_not_in: [String] paid: String paid_not: String paid_lt: String @@ -12811,6 +12820,8 @@ enum SortBillingReceiptHistoryRecordsBy { privilege_DESC penalty_ASC penalty_DESC + balanceUpdatedAt_ASC + balanceUpdatedAt_DESC paid_ASC paid_DESC id_ASC @@ -12847,6 +12858,7 @@ input BillingReceiptHistoryRecordUpdateInput { recalculation: String privilege: String penalty: String + balanceUpdatedAt: String paid: String toPayDetails: JSON services: JSON @@ -12888,6 +12900,7 @@ input BillingReceiptHistoryRecordCreateInput { recalculation: String privilege: String penalty: String + balanceUpdatedAt: String paid: String toPayDetails: JSON services: JSON @@ -13085,6 +13098,7 @@ type BillingReceipt { """ Amount of money that recipient doesn't pay for previous receipt. Example: "50.00", "-50.00" """ penalty: String + balanceUpdatedAt: String """ Amount of money that recipient already paid by current receipt. Example: "50.00", "-50.00" """ @@ -13277,6 +13291,14 @@ input BillingReceiptWhereInput { penalty_gte: String penalty_in: [String] penalty_not_in: [String] + balanceUpdatedAt: String + balanceUpdatedAt_not: String + balanceUpdatedAt_lt: String + balanceUpdatedAt_lte: String + balanceUpdatedAt_gt: String + balanceUpdatedAt_gte: String + balanceUpdatedAt_in: [String] + balanceUpdatedAt_not_in: [String] paid: String paid_not: String paid_lt: String @@ -13392,6 +13414,8 @@ enum SortBillingReceiptsBy { privilege_DESC penalty_ASC penalty_DESC + balanceUpdatedAt_ASC + balanceUpdatedAt_DESC paid_ASC paid_DESC receiver_ASC @@ -13432,6 +13456,7 @@ input BillingReceiptUpdateInput { recalculation: String privilege: String penalty: String + balanceUpdatedAt: String paid: String toPayDetails: BillingReceiptToPayDetailsFieldInput services: [BillingReceiptServiceFieldInput!] @@ -13470,6 +13495,7 @@ input BillingReceiptCreateInput { recalculation: String privilege: String penalty: String + balanceUpdatedAt: String paid: String toPayDetails: BillingReceiptToPayDetailsFieldInput services: [BillingReceiptServiceFieldInput!] diff --git a/apps/condo/schema.ts b/apps/condo/schema.ts index 7faf65b3b4d..3486f089eef 100644 --- a/apps/condo/schema.ts +++ b/apps/condo/schema.ts @@ -18290,6 +18290,7 @@ export type BillingReceipt = { acquiringIntegrationId?: Maybe /** Recipient balance on the receipt creation moment. Example: "50.00", "-50.00" */ balance?: Maybe + balanceUpdatedAt?: Maybe /** Can multiple receipts be united through this acquiring */ canGroupReceipts?: Maybe /** A category to print on display on the payment document. */ @@ -18355,6 +18356,7 @@ export type BillingReceipt = { export type BillingReceiptCreateInput = { account?: InputMaybe balance?: InputMaybe + balanceUpdatedAt?: InputMaybe category?: InputMaybe charge?: InputMaybe context?: InputMaybe @@ -18830,6 +18832,7 @@ export type BillingReceiptHistoryRecord = { _label_?: Maybe account?: Maybe balance?: Maybe + balanceUpdatedAt?: Maybe category?: Maybe charge?: Maybe context?: Maybe @@ -18867,6 +18870,7 @@ export type BillingReceiptHistoryRecord = { export type BillingReceiptHistoryRecordCreateInput = { account?: InputMaybe balance?: InputMaybe + balanceUpdatedAt?: InputMaybe category?: InputMaybe charge?: InputMaybe context?: InputMaybe @@ -18909,6 +18913,7 @@ export enum BillingReceiptHistoryRecordHistoryActionType { export type BillingReceiptHistoryRecordUpdateInput = { account?: InputMaybe balance?: InputMaybe + balanceUpdatedAt?: InputMaybe category?: InputMaybe charge?: InputMaybe context?: InputMaybe @@ -18950,6 +18955,14 @@ export type BillingReceiptHistoryRecordWhereInput = { account_not?: InputMaybe account_not_in?: InputMaybe>> balance?: InputMaybe + balanceUpdatedAt?: InputMaybe + balanceUpdatedAt_gt?: InputMaybe + balanceUpdatedAt_gte?: InputMaybe + balanceUpdatedAt_in?: InputMaybe>> + balanceUpdatedAt_lt?: InputMaybe + balanceUpdatedAt_lte?: InputMaybe + balanceUpdatedAt_not?: InputMaybe + balanceUpdatedAt_not_in?: InputMaybe>> balance_gt?: InputMaybe balance_gte?: InputMaybe balance_in?: InputMaybe>> @@ -19267,6 +19280,7 @@ export type BillingReceiptToPayDetailsFieldInput = { export type BillingReceiptUpdateInput = { account?: InputMaybe balance?: InputMaybe + balanceUpdatedAt?: InputMaybe category?: InputMaybe charge?: InputMaybe context?: InputMaybe @@ -19303,6 +19317,14 @@ export type BillingReceiptWhereInput = { account?: InputMaybe account_is_null?: InputMaybe balance?: InputMaybe + balanceUpdatedAt?: InputMaybe + balanceUpdatedAt_gt?: InputMaybe + balanceUpdatedAt_gte?: InputMaybe + balanceUpdatedAt_in?: InputMaybe>> + balanceUpdatedAt_lt?: InputMaybe + balanceUpdatedAt_lte?: InputMaybe + balanceUpdatedAt_not?: InputMaybe + balanceUpdatedAt_not_in?: InputMaybe>> balance_gt?: InputMaybe balance_gte?: InputMaybe balance_in?: InputMaybe>> @@ -78927,6 +78949,8 @@ export enum SortBillingReceiptFilesBy { } export enum SortBillingReceiptHistoryRecordsBy { + BalanceUpdatedAtAsc = 'balanceUpdatedAt_ASC', + BalanceUpdatedAtDesc = 'balanceUpdatedAt_DESC', BalanceAsc = 'balance_ASC', BalanceDesc = 'balance_DESC', ChargeAsc = 'charge_ASC', @@ -78970,6 +78994,8 @@ export enum SortBillingReceiptHistoryRecordsBy { export enum SortBillingReceiptsBy { AccountAsc = 'account_ASC', AccountDesc = 'account_DESC', + BalanceUpdatedAtAsc = 'balanceUpdatedAt_ASC', + BalanceUpdatedAtDesc = 'balanceUpdatedAt_DESC', BalanceAsc = 'balance_ASC', BalanceDesc = 'balance_DESC', CategoryAsc = 'category_ASC', From 5b6ea933041df2b29e88e1e2acb12b75c02fa45c Mon Sep 17 00:00:00 2001 From: Dmitry Kovyazin Date: Tue, 26 Nov 2024 13:06:26 +0500 Subject: [PATCH 2/7] feat(condo): DOMA-10747 removed console.log --- .../schema/resolvers/receiptResolver.js | 1 - ...illingreceipt_balanceupdatedat_and_more.js | 38 +++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 apps/condo/migrations/20241126120343-0439_billingreceipt_balanceupdatedat_and_more.js diff --git a/apps/condo/domains/billing/schema/resolvers/receiptResolver.js b/apps/condo/domains/billing/schema/resolvers/receiptResolver.js index 0305c6c6456..2d3f3de5ca9 100644 --- a/apps/condo/domains/billing/schema/resolvers/receiptResolver.js +++ b/apps/condo/domains/billing/schema/resolvers/receiptResolver.js @@ -51,7 +51,6 @@ class ReceiptResolver extends Resolver { ) if (!isEmpty(updateInput)) { if (updateInput.hasOwnProperty('toPay') || updateInput.hasOwnProperty('toPayDetails')) { - console.error('BALANCE UPDATE') updateInput['balanceUpdatedAt'] = new Date().toISOString() } try { diff --git a/apps/condo/migrations/20241126120343-0439_billingreceipt_balanceupdatedat_and_more.js b/apps/condo/migrations/20241126120343-0439_billingreceipt_balanceupdatedat_and_more.js new file mode 100644 index 00000000000..0af5d87b28a --- /dev/null +++ b/apps/condo/migrations/20241126120343-0439_billingreceipt_balanceupdatedat_and_more.js @@ -0,0 +1,38 @@ +// auto generated by kmigrator +// KMIGRATOR:0439_billingreceipt_balanceupdatedat_and_more:IyBHZW5lcmF0ZWQgYnkgRGphbmdvIDUuMC4zIG9uIDIwMjQtMTEtMjYgMDc6MDMKCmZyb20gZGphbmdvLmRiIGltcG9ydCBtaWdyYXRpb25zLCBtb2RlbHMKCgpjbGFzcyBNaWdyYXRpb24obWlncmF0aW9ucy5NaWdyYXRpb24pOgoKICAgIGRlcGVuZGVuY2llcyA9IFsKICAgICAgICAoJ19kamFuZ29fc2NoZW1hJywgJzA0MzhfYXV0b18yMDI0MTExMl8xMTU5JyksCiAgICBdCgogICAgb3BlcmF0aW9ucyA9IFsKICAgICAgICBtaWdyYXRpb25zLkFkZEZpZWxkKAogICAgICAgICAgICBtb2RlbF9uYW1lPSdiaWxsaW5ncmVjZWlwdCcsCiAgICAgICAgICAgIG5hbWU9J2JhbGFuY2VVcGRhdGVkQXQnLAogICAgICAgICAgICBmaWVsZD1tb2RlbHMuRGF0ZVRpbWVGaWVsZChibGFuaz1UcnVlLCBkYl9pbmRleD1UcnVlLCBudWxsPVRydWUpLAogICAgICAgICksCiAgICAgICAgbWlncmF0aW9ucy5BZGRGaWVsZCgKICAgICAgICAgICAgbW9kZWxfbmFtZT0nYmlsbGluZ3JlY2VpcHRoaXN0b3J5cmVjb3JkJywKICAgICAgICAgICAgbmFtZT0nYmFsYW5jZVVwZGF0ZWRBdCcsCiAgICAgICAgICAgIGZpZWxkPW1vZGVscy5EYXRlVGltZUZpZWxkKGJsYW5rPVRydWUsIG51bGw9VHJ1ZSksCiAgICAgICAgKSwKICAgIF0K + +exports.up = async (knex) => { + await knex.raw(` + BEGIN; +SET statement_timeout = '1500s'; +-- +-- Add field balanceUpdatedAt to billingreceipt +-- +ALTER TABLE "BillingReceipt" ADD COLUMN "balanceUpdatedAt" timestamp with time zone NULL; +-- +-- Add field balanceUpdatedAt to billingreceipthistoryrecord +-- +ALTER TABLE "BillingReceiptHistoryRecord" ADD COLUMN "balanceUpdatedAt" timestamp with time zone NULL; +CREATE INDEX "BillingReceipt_balanceUpdatedAt_499ae0a2" ON "BillingReceipt" ("balanceUpdatedAt"); +SET statement_timeout = '10s'; + +COMMIT; + + `) +} + +exports.down = async (knex) => { + await knex.raw(` + BEGIN; +-- +-- Add field balanceUpdatedAt to billingreceipthistoryrecord +-- +ALTER TABLE "BillingReceiptHistoryRecord" DROP COLUMN "balanceUpdatedAt" CASCADE; +-- +-- Add field balanceUpdatedAt to billingreceipt +-- +ALTER TABLE "BillingReceipt" DROP COLUMN "balanceUpdatedAt" CASCADE; +COMMIT; + + `) +} From 39a3ec4e07b4f844ed3bcbf71ab25d9d3711f873 Mon Sep 17 00:00:00 2001 From: Dmitry Kovyazin Date: Tue, 26 Nov 2024 13:08:28 +0500 Subject: [PATCH 3/7] feat(condo): DOMA-10747 removed console.log --- .../schema/AllResidentBillingReceiptsService.test.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/apps/condo/domains/billing/schema/AllResidentBillingReceiptsService.test.js b/apps/condo/domains/billing/schema/AllResidentBillingReceiptsService.test.js index f43b009019f..dd5d5bec89c 100644 --- a/apps/condo/domains/billing/schema/AllResidentBillingReceiptsService.test.js +++ b/apps/condo/domains/billing/schema/AllResidentBillingReceiptsService.test.js @@ -301,16 +301,11 @@ describe('AllResidentBillingReceiptsService', () => { const payAmount = '5000.00' const jsonReceipt = utils.createJSONReceipt({ importId, accountNumber, toPay: payAmount, toPayDetails: { charge: payAmount } }) const [[{ id: receiptId }]] = await utils.createReceipts([jsonReceipt]) - console.error('====== 1.') const resident = await utils.createResident() const [{ id: serviceConsumerId }] = await utils.createServiceConsumer(resident, accountNumber) await utils.payForReceipt(receiptId, serviceConsumerId) - console.error('====== 2.') - const [[{ id: updatedReceiptId }]] = await utils.createReceipts([{ ...jsonReceipt, toPay: '0.00', toPayDetails: { charge: payAmount, paid: payAmount } }]) expect(updatedReceiptId).toEqual(receiptId) - console.error('====== 3.') - const receiptsAfterPayment = await ResidentBillingReceipt.getAll(utils.clients.resident, { serviceConsumer: { resident: { id: resident.id } }, }) @@ -352,7 +347,6 @@ describe('AllResidentBillingReceiptsService', () => { serviceConsumer: { resident: { id: resident.id } }, }) const receiptAfterPayment = receiptsAfterPayment.find(({ id }) => id === receiptId ) - console.error(receiptAfterPayment) expect(Big(receiptAfterPayment.paid).toFixed(2)).toEqual(remainPay) expect(Big(receiptAfterPayment.toPayDetails.paid).toFixed(2)).toEqual(partialPay) }) From b2473bcaf41dfbaabfe20f34b467333ae8830682 Mon Sep 17 00:00:00 2001 From: Dmitry Kovyazin Date: Wed, 27 Nov 2024 10:21:55 +0500 Subject: [PATCH 4/7] feat(condo): DOMA-10747 rebuild migration --- ...illingreceipt_balanceupdatedat_and_more.js | 38 ------------------- 1 file changed, 38 deletions(-) delete mode 100644 apps/condo/migrations/20241126120343-0439_billingreceipt_balanceupdatedat_and_more.js diff --git a/apps/condo/migrations/20241126120343-0439_billingreceipt_balanceupdatedat_and_more.js b/apps/condo/migrations/20241126120343-0439_billingreceipt_balanceupdatedat_and_more.js deleted file mode 100644 index 0af5d87b28a..00000000000 --- a/apps/condo/migrations/20241126120343-0439_billingreceipt_balanceupdatedat_and_more.js +++ /dev/null @@ -1,38 +0,0 @@ -// auto generated by kmigrator -// KMIGRATOR:0439_billingreceipt_balanceupdatedat_and_more:IyBHZW5lcmF0ZWQgYnkgRGphbmdvIDUuMC4zIG9uIDIwMjQtMTEtMjYgMDc6MDMKCmZyb20gZGphbmdvLmRiIGltcG9ydCBtaWdyYXRpb25zLCBtb2RlbHMKCgpjbGFzcyBNaWdyYXRpb24obWlncmF0aW9ucy5NaWdyYXRpb24pOgoKICAgIGRlcGVuZGVuY2llcyA9IFsKICAgICAgICAoJ19kamFuZ29fc2NoZW1hJywgJzA0MzhfYXV0b18yMDI0MTExMl8xMTU5JyksCiAgICBdCgogICAgb3BlcmF0aW9ucyA9IFsKICAgICAgICBtaWdyYXRpb25zLkFkZEZpZWxkKAogICAgICAgICAgICBtb2RlbF9uYW1lPSdiaWxsaW5ncmVjZWlwdCcsCiAgICAgICAgICAgIG5hbWU9J2JhbGFuY2VVcGRhdGVkQXQnLAogICAgICAgICAgICBmaWVsZD1tb2RlbHMuRGF0ZVRpbWVGaWVsZChibGFuaz1UcnVlLCBkYl9pbmRleD1UcnVlLCBudWxsPVRydWUpLAogICAgICAgICksCiAgICAgICAgbWlncmF0aW9ucy5BZGRGaWVsZCgKICAgICAgICAgICAgbW9kZWxfbmFtZT0nYmlsbGluZ3JlY2VpcHRoaXN0b3J5cmVjb3JkJywKICAgICAgICAgICAgbmFtZT0nYmFsYW5jZVVwZGF0ZWRBdCcsCiAgICAgICAgICAgIGZpZWxkPW1vZGVscy5EYXRlVGltZUZpZWxkKGJsYW5rPVRydWUsIG51bGw9VHJ1ZSksCiAgICAgICAgKSwKICAgIF0K - -exports.up = async (knex) => { - await knex.raw(` - BEGIN; -SET statement_timeout = '1500s'; --- --- Add field balanceUpdatedAt to billingreceipt --- -ALTER TABLE "BillingReceipt" ADD COLUMN "balanceUpdatedAt" timestamp with time zone NULL; --- --- Add field balanceUpdatedAt to billingreceipthistoryrecord --- -ALTER TABLE "BillingReceiptHistoryRecord" ADD COLUMN "balanceUpdatedAt" timestamp with time zone NULL; -CREATE INDEX "BillingReceipt_balanceUpdatedAt_499ae0a2" ON "BillingReceipt" ("balanceUpdatedAt"); -SET statement_timeout = '10s'; - -COMMIT; - - `) -} - -exports.down = async (knex) => { - await knex.raw(` - BEGIN; --- --- Add field balanceUpdatedAt to billingreceipthistoryrecord --- -ALTER TABLE "BillingReceiptHistoryRecord" DROP COLUMN "balanceUpdatedAt" CASCADE; --- --- Add field balanceUpdatedAt to billingreceipt --- -ALTER TABLE "BillingReceipt" DROP COLUMN "balanceUpdatedAt" CASCADE; -COMMIT; - - `) -} From f5178ae12f1a6605f11dc523472044e5517409a0 Mon Sep 17 00:00:00 2001 From: Dmitry Kovyazin Date: Wed, 27 Nov 2024 10:24:14 +0500 Subject: [PATCH 5/7] feat(condo): DOMA-10747 rebuild migration --- .../domains/billing/schema/BillingReceipt.js | 2 +- ...illingreceipt_balanceupdatedat_and_more.js | 34 +++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 apps/condo/migrations/20241127102349-0440_billingreceipt_balanceupdatedat_and_more.js diff --git a/apps/condo/domains/billing/schema/BillingReceipt.js b/apps/condo/domains/billing/schema/BillingReceipt.js index a41a4f50233..f0d026993f2 100644 --- a/apps/condo/domains/billing/schema/BillingReceipt.js +++ b/apps/condo/domains/billing/schema/BillingReceipt.js @@ -136,8 +136,8 @@ const BillingReceipt = new GQLListSchema('BillingReceipt', { }, balanceUpdatedAt: { + schemaDoc: 'Last date time when the balance was updated', type: 'DateTimeUtc', - kmigratorOptions: { db_index: true }, isRequired: false, }, diff --git a/apps/condo/migrations/20241127102349-0440_billingreceipt_balanceupdatedat_and_more.js b/apps/condo/migrations/20241127102349-0440_billingreceipt_balanceupdatedat_and_more.js new file mode 100644 index 00000000000..04bf98c7a81 --- /dev/null +++ b/apps/condo/migrations/20241127102349-0440_billingreceipt_balanceupdatedat_and_more.js @@ -0,0 +1,34 @@ +// auto generated by kmigrator +// KMIGRATOR:0440_billingreceipt_balanceupdatedat_and_more:IyBHZW5lcmF0ZWQgYnkgRGphbmdvIDUuMC4zIG9uIDIwMjQtMTEtMjcgMDU6MjMKCmZyb20gZGphbmdvLmRiIGltcG9ydCBtaWdyYXRpb25zLCBtb2RlbHMKCgpjbGFzcyBNaWdyYXRpb24obWlncmF0aW9ucy5NaWdyYXRpb24pOgoKICAgIGRlcGVuZGVuY2llcyA9IFsKICAgICAgICAoJ19kamFuZ29fc2NoZW1hJywgJzA0MzlfYXV0b18yMDI0MTEyNV8wNzAyJyksCiAgICBdCgogICAgb3BlcmF0aW9ucyA9IFsKICAgICAgICBtaWdyYXRpb25zLkFkZEZpZWxkKAogICAgICAgICAgICBtb2RlbF9uYW1lPSdiaWxsaW5ncmVjZWlwdCcsCiAgICAgICAgICAgIG5hbWU9J2JhbGFuY2VVcGRhdGVkQXQnLAogICAgICAgICAgICBmaWVsZD1tb2RlbHMuRGF0ZVRpbWVGaWVsZChibGFuaz1UcnVlLCBudWxsPVRydWUpLAogICAgICAgICksCiAgICAgICAgbWlncmF0aW9ucy5BZGRGaWVsZCgKICAgICAgICAgICAgbW9kZWxfbmFtZT0nYmlsbGluZ3JlY2VpcHRoaXN0b3J5cmVjb3JkJywKICAgICAgICAgICAgbmFtZT0nYmFsYW5jZVVwZGF0ZWRBdCcsCiAgICAgICAgICAgIGZpZWxkPW1vZGVscy5EYXRlVGltZUZpZWxkKGJsYW5rPVRydWUsIG51bGw9VHJ1ZSksCiAgICAgICAgKSwKICAgIF0K + +exports.up = async (knex) => { + await knex.raw(` + BEGIN; +-- +-- Add field balanceUpdatedAt to billingreceipt +-- +ALTER TABLE "BillingReceipt" ADD COLUMN "balanceUpdatedAt" timestamp with time zone NULL; +-- +-- Add field balanceUpdatedAt to billingreceipthistoryrecord +-- +ALTER TABLE "BillingReceiptHistoryRecord" ADD COLUMN "balanceUpdatedAt" timestamp with time zone NULL; +COMMIT; + + `) +} + +exports.down = async (knex) => { + await knex.raw(` + BEGIN; +-- +-- Add field balanceUpdatedAt to billingreceipthistoryrecord +-- +ALTER TABLE "BillingReceiptHistoryRecord" DROP COLUMN "balanceUpdatedAt" CASCADE; +-- +-- Add field balanceUpdatedAt to billingreceipt +-- +ALTER TABLE "BillingReceipt" DROP COLUMN "balanceUpdatedAt" CASCADE; +COMMIT; + + `) +} From 8df1e40be3562b39dc3a2e8a095f257870ba6c75 Mon Sep 17 00:00:00 2001 From: Dmitry Kovyazin Date: Wed, 27 Nov 2024 10:26:27 +0500 Subject: [PATCH 6/7] feat(condo): DOMA-10747 rebuild migration --- ...41127102349-0440_billingreceipt_balanceupdatedat_and_more.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/condo/migrations/20241127102349-0440_billingreceipt_balanceupdatedat_and_more.js b/apps/condo/migrations/20241127102349-0440_billingreceipt_balanceupdatedat_and_more.js index 04bf98c7a81..61ec790491c 100644 --- a/apps/condo/migrations/20241127102349-0440_billingreceipt_balanceupdatedat_and_more.js +++ b/apps/condo/migrations/20241127102349-0440_billingreceipt_balanceupdatedat_and_more.js @@ -4,6 +4,7 @@ exports.up = async (knex) => { await knex.raw(` BEGIN; +SET statement_timeout = '1500s'; -- -- Add field balanceUpdatedAt to billingreceipt -- @@ -12,6 +13,7 @@ ALTER TABLE "BillingReceipt" ADD COLUMN "balanceUpdatedAt" timestamp with time z -- Add field balanceUpdatedAt to billingreceipthistoryrecord -- ALTER TABLE "BillingReceiptHistoryRecord" ADD COLUMN "balanceUpdatedAt" timestamp with time zone NULL; +SET statement_timeout = '10s'; COMMIT; `) From 0557cb75c5a2e0015d0b305c5e334e2fbff92005 Mon Sep 17 00:00:00 2001 From: Dmitry Kovyazin Date: Wed, 27 Nov 2024 12:34:57 +0500 Subject: [PATCH 7/7] feat(condo): DOMA-10747 rebuild schema --- apps/condo/schema.graphql | 2 ++ apps/condo/schema.ts | 1 + 2 files changed, 3 insertions(+) diff --git a/apps/condo/schema.graphql b/apps/condo/schema.graphql index 78cd07aa8fc..761efb2360c 100644 --- a/apps/condo/schema.graphql +++ b/apps/condo/schema.graphql @@ -13098,6 +13098,8 @@ type BillingReceipt { """ Amount of money that recipient doesn't pay for previous receipt. Example: "50.00", "-50.00" """ penalty: String + + """ Last date time when the balance was updated """ balanceUpdatedAt: String """ Amount of money that recipient already paid by current receipt. Example: "50.00", "-50.00" diff --git a/apps/condo/schema.ts b/apps/condo/schema.ts index 3486f089eef..43a9941fad4 100644 --- a/apps/condo/schema.ts +++ b/apps/condo/schema.ts @@ -18290,6 +18290,7 @@ export type BillingReceipt = { acquiringIntegrationId?: Maybe /** Recipient balance on the receipt creation moment. Example: "50.00", "-50.00" */ balance?: Maybe + /** Last date time when the balance was updated */ balanceUpdatedAt?: Maybe /** Can multiple receipts be united through this acquiring */ canGroupReceipts?: Maybe