@merkaly/api 0.25.0 → 0.25.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,8 @@
1
1
  export * from './payment.entity';
2
+ export * from './payment.attempt.entity';
2
3
  export * from './payment.gateway.entity';
3
4
  export * from './payment.enum';
4
5
  export * from './request.validator';
5
6
  export * from './payment.transition';
7
+ export * from './report';
8
+ export * from './report.request.validator';
@@ -1,3 +1,4 @@
1
1
  export * from './payment.enum.js';
2
2
  export * from './request.validator.js';
3
3
  export * from './payment.transition.js';
4
+ export * from './report.request.validator.js';
@@ -0,0 +1,26 @@
1
+ import { Schema as MongoSchema } from 'mongoose';
2
+ import { FinancePaymentMethodEnum } from './payment.enum.js';
3
+ import { FinancePaymentGatewayCardEntity } from './payment.gateway.entity.js';
4
+ import type { PaymentChargeStatusEnum } from '../../integration/payment';
5
+ export type FinancePaymentAttemptStatus = PaymentChargeStatusEnum | 'UNKNOWN';
6
+ export declare class FinancePaymentAttemptEntity {
7
+ reference?: string | null;
8
+ method: FinancePaymentMethodEnum;
9
+ status: FinancePaymentAttemptStatus;
10
+ rawStatus: string;
11
+ amount: number;
12
+ message?: string | null;
13
+ card?: FinancePaymentGatewayCardEntity | null;
14
+ expiresAt?: Date | null;
15
+ createdAt: Date;
16
+ syncedAt: Date;
17
+ }
18
+ export declare const FinancePaymentAttemptSchema: MongoSchema<FinancePaymentAttemptEntity, import("mongoose").Model<FinancePaymentAttemptEntity, any, any, any, import("mongoose").Document<unknown, any, FinancePaymentAttemptEntity, any, {}> & FinancePaymentAttemptEntity & {
19
+ _id: import("mongoose").Types.ObjectId;
20
+ } & {
21
+ __v: number;
22
+ }, any>, {}, {}, {}, {}, import("mongoose").DefaultSchemaOptions, FinancePaymentAttemptEntity, import("mongoose").Document<unknown, {}, import("mongoose").FlatRecord<FinancePaymentAttemptEntity>, {}, import("mongoose").ResolveSchemaOptions<import("mongoose").DefaultSchemaOptions>> & import("mongoose").FlatRecord<FinancePaymentAttemptEntity> & {
23
+ _id: import("mongoose").Types.ObjectId;
24
+ } & {
25
+ __v: number;
26
+ }>;
@@ -4,6 +4,7 @@ import { AbstractEntity } from '../../abstract.entity.js';
4
4
  import { StatusEntity } from '../../status.plugin.js';
5
5
  import { ITransitionable } from '../../transitionable.interface.js';
6
6
  import { FinancePaymentMethodEnum, FinancePaymentStatusEnum, FinancePaymentTypeEnum } from './payment.enum.js';
7
+ import { FinancePaymentAttemptEntity } from './payment.attempt.entity.js';
7
8
  import { FinancePaymentGatewayEntity } from './payment.gateway.entity.js';
8
9
  export type OrderEntity = OrderSaleEntity | OrderPurchaseEntity;
9
10
  export declare class FinancePaymentEntity extends AbstractEntity implements ITransitionable<FinancePaymentStatusEnum> {
@@ -14,6 +15,7 @@ export declare class FinancePaymentEntity extends AbstractEntity implements ITra
14
15
  fee: number;
15
16
  method?: FinancePaymentMethodEnum | null;
16
17
  gateway?: FinancePaymentGatewayEntity | null;
18
+ attempts?: FinancePaymentAttemptEntity[];
17
19
  status: FinancePaymentStatusEnum;
18
20
  history: StatusEntity<FinancePaymentStatusEnum>[];
19
21
  readonly number: string;
@@ -0,0 +1,65 @@
1
+ import type { FinancePaymentAttemptStatus } from './payment.attempt.entity.js';
2
+ import type { FinancePaymentMethodEnum, FinancePaymentStatusEnum } from './payment.enum.js';
3
+ export type FinancePaymentReportStatus = FinancePaymentAttemptStatus;
4
+ export interface FinancePaymentReportTotal {
5
+ amount: number;
6
+ count: number;
7
+ }
8
+ export interface FinancePaymentReportFailure {
9
+ message: string;
10
+ orgId: string;
11
+ orgName: string;
12
+ }
13
+ export interface FinancePaymentReportStore {
14
+ attemptCount: number;
15
+ expiredCount: number;
16
+ lastPaymentAt: Date | null;
17
+ orgId: string;
18
+ orgName: string;
19
+ paidAmount: number;
20
+ paidCount: number;
21
+ rejectedCount: number;
22
+ }
23
+ export interface FinancePaymentReportSummary {
24
+ attempts: Partial<Record<FinancePaymentReportStatus, number>> & {
25
+ total: number;
26
+ };
27
+ failures: FinancePaymentReportFailure[];
28
+ from: Date;
29
+ methods: Partial<Record<FinancePaymentMethodEnum, FinancePaymentReportTotal>>;
30
+ paid: FinancePaymentReportTotal;
31
+ storeCount: number;
32
+ stores: FinancePaymentReportStore[];
33
+ to: Date;
34
+ }
35
+ export interface FinancePaymentReportCard {
36
+ brand: string | null;
37
+ last4: string | null;
38
+ }
39
+ export interface FinancePaymentReportItem {
40
+ amount: number;
41
+ attempt: number;
42
+ card: FinancePaymentReportCard | null;
43
+ createdAt: Date;
44
+ message: string | null;
45
+ method: FinancePaymentMethodEnum;
46
+ orgId: string;
47
+ orgName: string;
48
+ paid: boolean;
49
+ paymentId: string;
50
+ paymentStatus: FinancePaymentStatusEnum;
51
+ provider: string;
52
+ rawStatus: string;
53
+ reference: string | null;
54
+ saleId: string | null;
55
+ saleNumber: string | null;
56
+ status: FinancePaymentReportStatus;
57
+ syncedAt: Date;
58
+ }
59
+ export interface FinancePaymentReportList {
60
+ failures: FinancePaymentReportFailure[];
61
+ items: FinancePaymentReportItem[];
62
+ limit: number;
63
+ page: number;
64
+ total: number;
65
+ }
@@ -0,0 +1,14 @@
1
+ import { AbstractRequestValidator } from '../../abstract.validator.js';
2
+ import { FinancePaymentMethodEnum } from './payment.enum.js';
3
+ import type { FinancePaymentReportStatus } from './report.js';
4
+ export declare class FinancePaymentReportRangeRequestValidator extends AbstractRequestValidator {
5
+ from: string;
6
+ to: string;
7
+ }
8
+ export declare class FinancePaymentReportSearchRequestValidator extends FinancePaymentReportRangeRequestValidator {
9
+ org?: string;
10
+ status?: FinancePaymentReportStatus;
11
+ method?: FinancePaymentMethodEnum;
12
+ page?: number;
13
+ limit?: number;
14
+ }
@@ -0,0 +1,68 @@
1
+ import 'reflect-metadata';
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
11
+ import * as class_transformer_1 from "class-transformer";
12
+ import * as class_validator_1 from "class-validator";
13
+ import * as charge_enum_1 from '../../integration/payment/index.js';
14
+ import * as abstract_validator_1 from '../../abstract.validator.js';
15
+ import * as payment_enum_1 from './payment.enum.js';
16
+ const REPORT_STATUSES = [
17
+ ...Object.values(charge_enum_1.PaymentChargeStatusEnum),
18
+ 'UNKNOWN',
19
+ ];
20
+ export class FinancePaymentReportRangeRequestValidator extends abstract_validator_1.AbstractRequestValidator {
21
+ from;
22
+ to;
23
+ }
24
+ __decorate([
25
+ (0, class_validator_1.IsISO8601)(),
26
+ __metadata("design:type", String)
27
+ ], FinancePaymentReportRangeRequestValidator.prototype, "from", void 0);
28
+ __decorate([
29
+ (0, class_validator_1.IsISO8601)(),
30
+ __metadata("design:type", String)
31
+ ], FinancePaymentReportRangeRequestValidator.prototype, "to", void 0);
32
+ export class FinancePaymentReportSearchRequestValidator extends FinancePaymentReportRangeRequestValidator {
33
+ org;
34
+ status;
35
+ method;
36
+ page = 1;
37
+ limit = 25;
38
+ }
39
+ __decorate([
40
+ (0, class_validator_1.IsString)(),
41
+ (0, class_validator_1.IsOptional)(),
42
+ __metadata("design:type", String)
43
+ ], FinancePaymentReportSearchRequestValidator.prototype, "org", void 0);
44
+ __decorate([
45
+ (0, class_validator_1.IsIn)(REPORT_STATUSES),
46
+ (0, class_validator_1.IsOptional)(),
47
+ __metadata("design:type", String)
48
+ ], FinancePaymentReportSearchRequestValidator.prototype, "status", void 0);
49
+ __decorate([
50
+ (0, class_validator_1.IsEnum)(payment_enum_1.FinancePaymentMethodEnum),
51
+ (0, class_validator_1.IsOptional)(),
52
+ __metadata("design:type", String)
53
+ ], FinancePaymentReportSearchRequestValidator.prototype, "method", void 0);
54
+ __decorate([
55
+ (0, class_transformer_1.Transform)(({ value }) => (value ? Number(value) : 1)),
56
+ (0, class_validator_1.IsInt)(),
57
+ (0, class_validator_1.Min)(1),
58
+ (0, class_validator_1.IsOptional)(),
59
+ __metadata("design:type", Number)
60
+ ], FinancePaymentReportSearchRequestValidator.prototype, "page", void 0);
61
+ __decorate([
62
+ (0, class_transformer_1.Transform)(({ value }) => (value ? Number(value) : 25)),
63
+ (0, class_validator_1.IsInt)(),
64
+ (0, class_validator_1.Min)(1),
65
+ (0, class_validator_1.Max)(100),
66
+ (0, class_validator_1.IsOptional)(),
67
+ __metadata("design:type", Number)
68
+ ], FinancePaymentReportSearchRequestValidator.prototype, "limit", void 0);
@@ -47,8 +47,14 @@ export interface PaymentAccountOnboarding {
47
47
  documents: PaymentAccountDocument[];
48
48
  rejectReasons: string | null;
49
49
  }
50
+ export interface PaymentAccountPending {
51
+ amount: number;
52
+ count: number;
53
+ nextCreditDate: string | null;
54
+ }
50
55
  export interface PaymentAccountBalance {
51
56
  balance: number;
57
+ pending: PaymentAccountPending | null;
52
58
  }
53
59
  export interface PaymentAccountTransfer {
54
60
  id: string;
@@ -9,4 +9,6 @@ export declare class OrderSaleEntity extends TransactionEntity<OrderSaleStatusEn
9
9
  items: ItemEntity[];
10
10
  shipping?: OrderSaleShippingEntity;
11
11
  readonly purchases: OrderPurchaseEntity[];
12
+ readonly cost: number | null;
13
+ readonly profit: number | null;
12
14
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@merkaly/api",
3
- "version": "0.25.0",
3
+ "version": "0.25.1",
4
4
  "type": "module",
5
5
  "description": "Shared TypeScript interfaces and enums for Merkaly API",
6
6
  "repository": {