mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-08 05:25:41 +00:00
Merge pull request #226 from Tria-plc/alpha
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -29,3 +29,6 @@ coverage/
|
|||||||
*~
|
*~
|
||||||
\#*\#
|
\#*\#
|
||||||
.\#*
|
.\#*
|
||||||
|
branch_structure.json
|
||||||
|
temp_auto_push.bat
|
||||||
|
temp_interactive_push.bat
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -0,0 +1,29 @@
|
|||||||
|
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Amounts now carry the real/major price (callers pass e.g. 10.50, not minor units), which may be
|
||||||
|
* fractional. Widen amount_minor / confirmed_amount_minor from integer to double precision so the
|
||||||
|
* decimals are stored instead of silently rounded.
|
||||||
|
*/
|
||||||
|
export class AmountToDouble1782000000000 implements MigrationInterface {
|
||||||
|
name = "AmountToDouble1782000000000";
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
// integer -> double precision is an implicit widening cast (no USING needed).
|
||||||
|
await queryRunner.query(
|
||||||
|
`ALTER TABLE "edr_payment"."payment_intent" ALTER COLUMN "amount_minor" TYPE double precision`,
|
||||||
|
);
|
||||||
|
await queryRunner.query(
|
||||||
|
`ALTER TABLE "edr_payment"."payment_intent" ALTER COLUMN "confirmed_amount_minor" TYPE double precision`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(
|
||||||
|
`ALTER TABLE "edr_payment"."payment_intent" ALTER COLUMN "confirmed_amount_minor" TYPE integer USING round("confirmed_amount_minor")`,
|
||||||
|
);
|
||||||
|
await queryRunner.query(
|
||||||
|
`ALTER TABLE "edr_payment"."payment_intent" ALTER COLUMN "amount_minor" TYPE integer USING round("amount_minor")`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import {
|
import {
|
||||||
IsEnum,
|
IsEnum,
|
||||||
IsIn,
|
IsIn,
|
||||||
IsInt,
|
IsNumber,
|
||||||
IsOptional,
|
IsOptional,
|
||||||
IsPositive,
|
IsPositive,
|
||||||
IsString,
|
IsString,
|
||||||
@@ -46,9 +46,9 @@ export class InitiatePaymentRequestDto implements InitiatePaymentRequest {
|
|||||||
|
|
||||||
@ApiProperty({
|
@ApiProperty({
|
||||||
description:
|
description:
|
||||||
"Authoritative amount in minor units, computed server-side by the app",
|
"Authoritative amount computed server-side by the app. Accepts decimals "
|
||||||
})
|
})
|
||||||
@IsInt()
|
@IsNumber()
|
||||||
@IsPositive()
|
@IsPositive()
|
||||||
amountMinor!: number;
|
amountMinor!: number;
|
||||||
|
|
||||||
|
|||||||
@@ -71,12 +71,16 @@ export class PaymentIntent extends BaseEntity {
|
|||||||
})
|
})
|
||||||
providerTxnId?: string | null;
|
providerTxnId?: string | null;
|
||||||
|
|
||||||
/** App-asserted authoritative amount in minor units. */
|
/** App-asserted authoritative amount (real/major price; may be fractional, e.g. 10.50). */
|
||||||
@Column({ name: "amount_minor", type: "integer" })
|
@Column({ name: "amount_minor", type: "double precision" })
|
||||||
amountMinor!: number;
|
amountMinor!: number;
|
||||||
|
|
||||||
/** Provider-reported amount; reconciled against amount_minor (e.g. Waafi truncates decimals). */
|
/** Provider-reported amount; reconciled against amount_minor (e.g. Waafi truncates decimals). */
|
||||||
@Column({ name: "confirmed_amount_minor", type: "integer", nullable: true })
|
@Column({
|
||||||
|
name: "confirmed_amount_minor",
|
||||||
|
type: "double precision",
|
||||||
|
nullable: true,
|
||||||
|
})
|
||||||
confirmedAmountMinor?: number | null;
|
confirmedAmountMinor?: number | null;
|
||||||
|
|
||||||
@Column({ name: "currency", type: "varchar", length: 8 })
|
@Column({ name: "currency", type: "varchar", length: 8 })
|
||||||
|
|||||||
Reference in New Issue
Block a user