FE-170: new party management integration (#75)

This commit is contained in:
andrey 2017-02-07 22:28:42 +03:00 committed by Ildar Galeev
parent 07ce1a93ea
commit b3bb597d5a
115 changed files with 1573 additions and 1955 deletions

View File

@ -1,3 +1,3 @@
{
"capiUrl": "http://localhost:9000/v1"
"capiUrl": "http://api.rbk.money:8080/v1"
}

View File

@ -1,7 +1,7 @@
{
"realm" : "external",
"realm-public-key" : "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2KZPnAJs0SS6/w39mDTrWYRjM86IFteU/dPGpGQdOPwNe85Ep2leVN3/FBKVUMHsFTtFkVsg/VcCEfYBj22B0mZ8zV2hQUCNq1NV2b2LnYYrDmThmFOOTnpbBhEOMS8Wrzj3Yk7mcDtKlMzoBNIQ/Z54ffymkyiKX8XOw45K9Cx1Bp/SVjOnJlm0Qu/+zE40/XVpzgjbaqSc9+8B3tur2E03EVemOa6EFhu7ocKsbSR7/fG1nYOGKjACS1Z+VYQTMcRqxZlLw7kv3fxUaMDcK5p/16YWpWggflVy5w26IIJeDcsXG+X3LV6f6dyo9ZfOEvGqQZmPCohaSOgi+IRwAQIDAQAB",
"auth-server-url" : "http://localhost:8080/auth/",
"auth-server-url" : "http://auth.rbk.money:8080/auth/",
"ssl-required" : "external",
"resource" : "koffing",
"public-client" : true

View File

@ -1,5 +1,5 @@
{
"realm": "external",
"auth-server-url": "http://localhost:8080/auth/",
"auth-server-url": "http://auth.rbk.money:8080/auth/",
"resource": "tokenizer"
}

View File

@ -13,7 +13,6 @@ import { PaymentMethodComponent } from './components/analytic-selection/dashboar
import { ConversionComponent } from './components/analytic-selection/dashboard/conversion/conversion.component';
import { RevenueComponent } from './components/analytic-selection/dashboard/revenue/revenue.component';
import { GeolocationComponent } from './components/analytic-selection/dashboard/geolocation/geolocation.component';
import { InfoPanelComponent } from './components/analytic-selection/dashboard/info-panel/info-panel.component';
import { AnalyticSelectionComponent } from './components/analytic-selection/analytic-selection.component';
import { PaginationPipe } from './components/analytic-selection/finance/paginate/pagination.pipe';
import { PaymentStatusPipe } from './components/analytic-selection/finance/search-result/payment-statuses.pipe';
@ -43,7 +42,6 @@ import { BackendModule } from 'koffing/backend/backend.module';
ConversionComponent,
RevenueComponent,
GeolocationComponent,
InfoPanelComponent,
PaymentStatusPipe,
RoubleCurrencyPipe,
PaginationPipe

View File

@ -5,8 +5,8 @@
.col-xs-12.col-sm-1
label.control-label Магазин
.col-xs-12.col-sm-6
kof-select(*ngIf="selectItems.length", [(ngModel)]="selectedShopID", [items]="selectItems", (onChange)="navigateToShop()", [modelOptions]="{standalone: true}", name='shopId')
ul.nav.nav-tabs.bar_tabs(*ngIf="selectedShopID")
kof-select(*ngIf="shopItems.length", [(ngModel)]="currentShopID", [items]="shopItems", (onChange)="navigateToShop()", [modelOptions]="{standalone: true}", name='shopId')
ul.nav.nav-tabs.bar_tabs(*ngIf="currentShopID")
li.hand-cursor([routerLink]="['dashboard']", [routerLinkActive]="['active']")
a Статистика
li.hand-cursor([routerLink]="['finance']", [routerLinkActive]="['active']")

View File

@ -12,9 +12,8 @@ import { SelectItem } from 'koffing/common/common.module';
})
export class AnalyticSelectionComponent implements OnInit {
public selectedShopID: string;
public selectItems: SelectItem[] = [];
public currentShopID: number;
public shopItems: SelectItem[] = [];
constructor(
private route: ActivatedRoute,
@ -24,9 +23,9 @@ export class AnalyticSelectionComponent implements OnInit {
public ngOnInit() {
this.shopService.getShops().then((shops: Shop[]) => {
const routeShopID = this.route.snapshot.params['shopID'];
this.selectItems = _.map(shops, (shop: Shop) => new SelectItem(shop.shopID, shop.shopDetails.name));
this.selectedShopID = routeShopID ? routeShopID : this.selectItems[0].value;
const routeShopID = Number(this.route.snapshot.params['shopID']);
this.shopItems = _.map(shops, (shop: Shop) => new SelectItem(shop.id, shop.details.name));
this.currentShopID = routeShopID ? routeShopID : this.shopItems[0].value;
this.navigateToShop();
});
}
@ -34,6 +33,6 @@ export class AnalyticSelectionComponent implements OnInit {
public navigateToShop() {
const hasChildren = this.route.children.length > 0;
const childComponent = hasChildren ? this.route.children[0].routeConfig.path : 'dashboard';
this.router.navigate(['analytics', this.selectedShopID, childComponent]);
this.router.navigate(['analytics', this.currentShopID, childComponent]);
}
}

View File

@ -13,22 +13,54 @@
button.btn.btn-default(style="margin-bottom: 0; margin-right: 0; margin-left: 5px;", (click)="loadData()") Показать
.row
.col-xs-12
kof-info-panel([uniqueCount]="uniqueCount", [successfulCount]="successfulCount",
[unfinishedCount]="unfinishedCount", [profit]="profit", [account]="account", [isLoading]="isInfoPanelLoading")
.row.tile_count
.col-xs-6.col-sm-4.col-md-2.tile_stats_count
span.count_top Оборот
.dashboard_stats_count
kof-loading([isLoading]="profit === undefined")
div {{profit | kofRoubleCurrency}}
span.count_bottom Рублей
.col-xs-6.col-sm-4.col-md-2.tile_stats_count
span.count_top Основной счет
.dashboard_stats_count
kof-loading([isLoading]="settlementBalance === undefined")
div {{settlementBalance | kofRoubleCurrency}}
span.count_bottom Рублей
.col-xs-6.col-sm-4.col-md-2.tile_stats_count
span.count_top Гарантийный счет
.dashboard_stats_count
kof-loading([isLoading]="guaranteeBalance === undefined")
div {{guaranteeBalance | kofRoubleCurrency}}
span.count_bottom Рублей
.col-xs-6.col-sm-4.col-md-2.tile_stats_count
span.count_top Успешных платежей
.dashboard_stats_count
kof-loading([isLoading]="successfulCount === undefined")
div {{successfulCount}}
.col-xs-6.col-sm-4.col-md-2.tile_stats_count
span.count_top Незавершенных платежей
.dashboard_stats_count
kof-loading([isLoading]="unfinishedCount === undefined")
div {{unfinishedCount}}
.col-xs-6.col-sm-4.col-md-2.tile_stats_count
span.count_top Уникальных плательщиков
.dashboard_stats_count
kof-loading([isLoading]="uniqueCount === undefined")
div {{uniqueCount}}
.row
.col-xs-12
.x_panel.tile
.x_title
h4 Оборот
.x_content
kof-revenue([fromTime]="chartFromTime", [chartData]="revenueChartData")
kof-revenue([fromTime]="fromTime", [chartData]="revenueChartData")
.row
.col-xs-12
.x_panel.tile
.x_title
h4 Конверсия оплат
.x_content
kof-conversion([fromTime]="chartFromTime", [chartData]="conversionChartData")
kof-conversion([fromTime]="fromTime", [chartData]="conversionChartData")
.row
.col-xs-12.col-sm-6
.x_panel.tile

View File

@ -1,18 +1,20 @@
import { Component, OnInit, ViewEncapsulation } from '@angular/core';
import { ActivatedRoute, Params } from '@angular/router';
import * as _ from 'lodash';
import * as moment from 'moment';
import { ChartDataConversionService } from './chart-data-conversion.service';
import { ShopService } from 'koffing/backend/services/shop.service';
import { AccountService } from 'koffing/backend/backend.module';
import { CustomerService } from 'koffing/backend/backend.module';
import { PaymentsService } from 'koffing/backend/backend.module';
import { RequestParams } from 'koffing/backend/backend.module';
import { PaymentGeoStat } from 'koffing/backend/backend.module';
import { PaymentsService } from 'koffing/backend/backend.module';
import { Conversion } from 'koffing/backend/backend.module';
import { GeolocationService } from 'koffing/backend/backend.module';
import { LocationName } from 'koffing/backend/backend.module';
import { GeoChartLabeled } from './geo-chart-labeled.class';
import { Shop } from 'koffing/backend/classes/shop.class';
import { GeoChartData } from './geo-chart-data.class';
@Component({
templateUrl: './dashboard.component.pug',
@ -23,202 +25,120 @@ export class DashboardComponent implements OnInit {
public fromTime: any;
public toTime: any;
public fromTimeDate: Date;
public toTimeDate: Date;
public uniqueCount: any;
public successfulCount: any;
public unfinishedCount: any;
public profit: any;
public account: any = {
general: {
ownAmount: 1
},
guarantee: {
ownAmount: 2
}
};
public chartFromTime: any;
public guaranteeBalance: any;
public settlementBalance: any;
public revenueChartData: any;
public conversionChartData: any;
public geoChartData: GeoChartLabeled = new GeoChartLabeled([], []);
public geoChartData: GeoChartLabeled;
public paymentMethodChartData: any;
public isInfoPanelLoading: boolean;
private fromTimeDate: Date;
private toTimeDate: Date;
private shopID: string;
private shopID: number;
constructor(private route: ActivatedRoute,
private customer: CustomerService,
private payments: PaymentsService,
private accounts: AccountService,
private geolocation: GeolocationService) { }
constructor(
private route: ActivatedRoute,
private customerService: CustomerService,
private paymentsService: PaymentsService,
private accountService: AccountService,
private shopService: ShopService,
private geolocation: GeolocationService
) {}
public ngOnInit() {
this.toTimeDate = new Date();
this.fromTimeDate = new Date();
this.fromTimeDate.setMonth(this.fromTimeDate.getMonth() - 1);
this.toTime = moment(this.toTimeDate).format();
this.fromTime = moment(this.fromTimeDate).format();
this.route.parent.params.subscribe((params: Params) => {
this.shopID = params['shopID'];
this.setInitialDate();
this.shopID = Number(params['shopID']);
this.loadData();
});
}
private loadRate() {
return new Promise((resolve) => {
this.customer.getRate(
this.shopID,
new RequestParams(
this.fromTime,
this.toTime
)
).then(
(rateStat: any) => {
this.uniqueCount = rateStat[0] ? rateStat[0].uniqueCount : 0;
resolve();
}
);
});
private loadData() {
this.loadPaymentMethod();
this.loadGeoChartData();
this.loadRate();
this.loadConversionStat();
this.loadRevenueStat();
this.loadAccounts();
}
private loadPaymentMethod() {
this.customer.getPaymentMethod(
this.customerService.getPaymentMethod(
this.shopID,
new RequestParams(
this.fromTime,
this.toTime,
'minute',
'1',
'bank_card'
)
).then(
(paymentMethodState: any) => {
this.paymentMethodChartData = ChartDataConversionService.toPaymentMethodChartData(paymentMethodState);
}
);
new RequestParams(this.fromTime, this.toTime, 'minute', '1', 'bankCard')
).then((paymentMethodState: any) => {
this.paymentMethodChartData = ChartDataConversionService.toPaymentMethodChartData(paymentMethodState);
});
}
private loadRate() {
this.customerService.getRate(
this.shopID,
new RequestParams(this.fromTime, this.toTime)
).then((rateStat: any) => {
this.uniqueCount = rateStat[0] ? rateStat[0].uniqueCount : 0;
});
}
private loadConversionStat() {
return new Promise((resolve) => {
this.payments.getConversionStat(
this.shopID,
new RequestParams(
this.fromTime,
this.toTime,
'minute',
'1'
)
).then(
(conversionStat: Conversion[]) => {
let paymentCountInfo: any;
paymentCountInfo = ChartDataConversionService.toPaymentCountInfo(conversionStat);
this.conversionChartData = ChartDataConversionService.toConversionChartData(conversionStat);
this.successfulCount = paymentCountInfo.successfulCount;
this.unfinishedCount = paymentCountInfo.unfinishedCount;
resolve();
}
);
this.paymentsService.getConversionStat(
this.shopID,
new RequestParams(this.fromTime, this.toTime, 'minute', '1')
).then((conversionStat: Conversion[]) => {
const paymentCountInfo = ChartDataConversionService.toPaymentCountInfo(conversionStat);
this.successfulCount = paymentCountInfo.successfulCount;
this.unfinishedCount = paymentCountInfo.unfinishedCount;
this.conversionChartData = ChartDataConversionService.toConversionChartData(conversionStat);
});
}
private loadGeoChartData() {
this.geolocation.getGeoChartData(
this.shopID,
new RequestParams(
this.fromTime,
this.toTime,
'day',
'1'
)
).then(
(geoData: PaymentGeoStat[]) => {
let unlabeledGeoChartData = ChartDataConversionService.toGeoChartData(geoData);
new RequestParams(this.fromTime, this.toTime, 'day', '1')
).then((geoData: PaymentGeoStat[]) => {
const unlabeledGeoChartData: GeoChartData = ChartDataConversionService.toGeoChartData(geoData);
if (unlabeledGeoChartData.geoIDs.length > 0 && unlabeledGeoChartData.data.length > 0) {
this.geolocation.getLocationNames(unlabeledGeoChartData.geoIDs, 'ru').then(
(locationNames: LocationName[]) => {
this.geoChartData = ChartDataConversionService.toLabeledGeoChartData(unlabeledGeoChartData, locationNames);
}
);
} else {
this.geoChartData = new GeoChartLabeled([], []);
}
);
});
}
private loadRevenueStat() {
return new Promise((resolve) => {
this.payments.getRevenueStat(
this.shopID,
new RequestParams(
this.fromTime,
this.toTime,
'minute',
'1'
)
).then(
(revenueStat: any) => {
this.revenueChartData = ChartDataConversionService.toRevenueChartData(revenueStat);
this.profit = ChartDataConversionService.toTotalProfit(revenueStat);
resolve();
}
);
this.paymentsService.getRevenueStat(
this.shopID,
new RequestParams(this.fromTime, this.toTime, 'minute', '1')
).then((revenueStat: any) => {
this.revenueChartData = ChartDataConversionService.toRevenueChartData(revenueStat);
this.profit = ChartDataConversionService.toTotalProfit(revenueStat);
});
}
private loadShopAccounts() {
return new Promise((resolve) => {
this.accounts.getShopAccounts(this.shopID).then(
(shopAccounts) => {
if (shopAccounts.length > 1) {
console.warn('shop accounts size > 1');
}
_.forEach(shopAccounts, item => {
this.accounts.getShopAccountDetails(
this.shopID,
item.generalID
).then(
(generalAccount: any) => {
this.account.general = generalAccount;
}
);
this.accounts.getShopAccountDetails(
this.shopID,
item.guaranteeID
).then(
(guaranteeAccount: any) => {
this.account.guarantee = guaranteeAccount;
}
);
});
resolve();
}
);
private loadAccounts() {
this.shopService.getShop(this.shopID).then((shop: Shop) => {
this.accountService.getAccount(shop.account.guaranteeID).then((account: any) => {
this.guaranteeBalance = account.ownAmount;
});
this.accountService.getAccount(shop.account.settlementID).then((account: any) => {
this.settlementBalance = account.ownAmount;
});
});
}
private loadData() {
this.fromTime = moment(this.fromTimeDate).format();
this.toTime = moment(this.toTimeDate).format();
this.chartFromTime = this.fromTime;
this.loadPaymentMethod();
this.loadGeoChartData();
this.isInfoPanelLoading = true;
Promise.all([
this.loadRate(),
this.loadConversionStat(),
this.loadRevenueStat(),
this.loadShopAccounts()
]).then(() => {
this.isInfoPanelLoading = false;
});
}
private setInitialDate() {
this.toTimeDate = new Date();
this.fromTimeDate = new Date();
this.fromTimeDate.setMonth( this.fromTimeDate.getMonth() - 1 );
}
}

View File

@ -2,8 +2,8 @@ kof-loading([isLoading]="isLoading")
div
canvas(
baseChart,
[data]="chartData.data",
[labels]="chartData.cityNames",
[data]="data",
[labels]="labels",
[chartType]="type",
[options]="options",
[colors]="chartColors",

View File

@ -1,4 +1,4 @@
import { Component, Input, OnInit, OnChanges } from '@angular/core';
import { Component, Input, OnChanges } from '@angular/core';
import { CHART_OPTIONS } from './../chart-options.const';
import { GeoChartLabeled } from './../geo-chart-labeled.class';
@ -7,10 +7,12 @@ import { GeoChartLabeled } from './../geo-chart-labeled.class';
selector: 'kof-geolocation',
templateUrl: './geolocation.component.pug'
})
export class GeolocationComponent implements OnInit, OnChanges {
export class GeolocationComponent implements OnChanges {
@Input()
public chartData: GeoChartLabeled;
public data: number[] = [];
public labels: string[] = [];
public type: string = 'doughnut';
public options: any = {
animation: false,
@ -21,14 +23,12 @@ export class GeolocationComponent implements OnInit, OnChanges {
};
public chartColors = [CHART_OPTIONS.DOUGHNUT.COLORS];
private isLoading: boolean;
public ngOnInit() {
this.isLoading = true;
}
private isLoading: boolean = true;
public ngOnChanges() {
if (this.chartData) {
this.data = this.chartData.data;
this.labels = this.chartData.cityNames;
this.isLoading = false;
}
}

View File

@ -1,34 +0,0 @@
.row.tile_count
.col-xs-6.col-sm-4.col-md-2.tile_stats_count
span.count_top Оборот
.dashboard_stats_count
kof-loading([isLoading]="isLoading")
div {{profit | kofRoubleCurrency}}
span.count_bottom Рублей
.col-xs-6.col-sm-4.col-md-2.tile_stats_count
span.count_top Основной счет
.dashboard_stats_count
kof-loading([isLoading]="isLoading")
div {{account.general.ownAmount | kofRoubleCurrency}}
span.count_bottom Рублей
.col-xs-6.col-sm-4.col-md-2.tile_stats_count
span.count_top Гарантийный счет
.dashboard_stats_count
kof-loading([isLoading]="isLoading")
div {{account.guarantee.ownAmount | kofRoubleCurrency}}
span.count_bottom Рублей
.col-xs-6.col-sm-4.col-md-2.tile_stats_count
span.count_top Успешных платежей
.dashboard_stats_count
kof-loading([isLoading]="isLoading")
div {{successfulCount}}
.col-xs-6.col-sm-4.col-md-2.tile_stats_count
span.count_top Незавершенных платежей
.dashboard_stats_count
kof-loading([isLoading]="isLoading")
div {{unfinishedCount}}
.col-xs-6.col-sm-4.col-md-2.tile_stats_count
span.count_top Уникальных плательщиков
.dashboard_stats_count
kof-loading([isLoading]="isLoading")
div {{uniqueCount}}

View File

@ -1,21 +0,0 @@
import { Component, Input } from '@angular/core';
@Component({
selector: 'kof-info-panel',
templateUrl: './info-panel.component.pug'
})
export class InfoPanelComponent {
@Input()
public uniqueCount: any;
@Input()
public successfulCount: any;
@Input()
public unfinishedCount: any;
@Input()
public profit: any;
@Input()
public account: any;
@Input()
public isLoading: boolean;
}

View File

@ -115,6 +115,6 @@ export class AuthHttpInterceptor extends Http {
function s4() {
return Math.floor((1 + Math.random()) * 0x10000).toString(16).substring(1);
}
return `${s4()}${s4()}-${s4()}-${s4()}-${s4()}-${s4()}${s4()}${s4()}`;
return `${s4()}${s4()}-${s4()}-${s4()}`;
}
}

View File

@ -7,7 +7,6 @@ import { ContractService } from './services/contract.service';
import { CustomerService } from './services/customer.service';
import { InvoiceService } from './services/invoice.service';
import { PaymentsService } from './services/payments.service';
import { PayoutAccountService } from './services/payout-account.service';
import { ShopService } from './services/shop.service';
import { ConfigService } from './services/config.service';
import { GeolocationService } from './services/geolocation.service';
@ -21,7 +20,6 @@ import { GeolocationService } from './services/geolocation.service';
CustomerService,
InvoiceService,
PaymentsService,
PayoutAccountService,
ShopService,
ConfigService,
GeolocationService
@ -37,21 +35,22 @@ export * from './services/contract.service';
export * from './services/customer.service';
export * from './services/invoice.service';
export * from './services/payments.service';
export * from './services/payout-account.service';
export * from './services/shop.service';
export * from './services/geolocation.service';
export * from './classes/account.class';
export * from './classes/bank-account.class';
export * from './classes/callback-handler.class';
export * from './classes/category.class';
export * from './classes/claim.class';
export * from './classes/contract.class';
export * from './classes/contractor.class';
export * from './classes/conversion.class';
export * from './classes/entity.class';
export * from './classes/legal-entity.class';
export * from './classes/geodata.class';
export * from './classes/invoice.class';
export * from './classes/payout-account.class';
export * from './classes/payout-tool.class';
export * from './classes/payout-tool-params.class';
export * from './classes/payout-tool-bank-account.class';
export * from './classes/request-params.class';
export * from './classes/revenue.class';
@ -59,4 +58,5 @@ export * from './classes/russian-legal-entity.class';
export * from './classes/shop.class';
export * from './classes/shop-detail.class';
export * from './classes/shop-item.class';
export * from './classes/shop-location.class';
export * from './classes/location-name.class';

View File

@ -0,0 +1,5 @@
export class Account {
public guaranteeID: string;
public settlementID: string;
public currency: string;
}

View File

@ -1,5 +1,5 @@
export class Category {
public categoryRef: number;
public categoryID: number;
public description: string;
public name: string;
}

View File

@ -0,0 +1,7 @@
import { Contractor } from 'koffing/backend/classes/contractor.class';
import { PayoutToolParams } from 'koffing/backend/classes/payout-tool-params.class';
export class ContractParams {
public contractor: Contractor;
public payoutToolParams: PayoutToolParams;
}

View File

@ -1,10 +1,13 @@
import { Contractor } from './contractor.class';
import { PayoutAccount } from './payout-account.class';
export class Contract {
public id: number;
public contractor: Contractor;
public concludedAt: string;
public validSince: string;
public validUntil: string;
public terminatedAt: string;
public payoutAccounts: PayoutAccount[];
constructor() {
this.contractor = new Contractor();
}
}

View File

@ -1,7 +1,12 @@
import { BankAccount } from './bank-account.class';
import { Entity } from './entity.class';
import { LegalEntity } from './legal-entity.class';
export class Contractor {
public bankAccount: BankAccount;
public entity: Entity;
public legalEntity: LegalEntity;
constructor() {
this.bankAccount = new BankAccount();
this.legalEntity = new LegalEntity();
}
}

View File

@ -0,0 +1,9 @@
import { ShopDetail } from 'koffing/backend/classes/shop-detail.class';
export class CreateShopArgs {
public categoryID: number;
public details: ShopDetail;
public contractID: number;
public payoutToolID: number;
public callbackUrl: string;
}

View File

@ -1,3 +1,3 @@
export class Entity {
export class LegalEntity {
public entityType: string;
}

View File

@ -1,7 +0,0 @@
import { PayoutTool } from './payout-tool.class';
export class PayoutAccount {
public id: number;
public currency: string;
public tool: PayoutTool;
}

View File

@ -1,6 +1,11 @@
import { PayoutTool } from './payout-tool.class';
import { PayoutToolParams } from './payout-tool-params.class';
import { BankAccount } from './bank-account.class';
export class PayoutToolBankAccount extends PayoutTool {
export class PayoutToolBankAccount extends PayoutToolParams {
public bankAccount: BankAccount;
constructor() {
super();
this.payoutToolType = 'PayoutToolBankAccount';
}
}

View File

@ -0,0 +1,4 @@
export class PayoutToolParams {
public payoutToolType: string;
public currency: string;
}

View File

@ -1,3 +1,10 @@
import { PayoutToolParams } from './payout-tool-params.class';
export class PayoutTool {
public payoutToolType: string;
public id: number;
public params: PayoutToolParams;
constructor() {
this.params = new PayoutToolParams();
}
}

View File

@ -3,7 +3,7 @@ export class RequestParams {
public toTime: string;
public splitUnit: string = 'minute';
public splitSize: string = '1';
public paymentMethod: string = 'bank_card';
public paymentMethod: string = 'bankCard';
constructor(fromTime: string, toTime: string, splitUnit?: string, splitSize?: string, paymentMethod?: string) {
this.fromTime = fromTime;

View File

@ -1,6 +1,6 @@
import { Entity } from './entity.class';
import { LegalEntity } from './legal-entity.class';
export class RussianLegalEntity extends Entity {
export class RussianLegalEntity extends LegalEntity {
public registeredName: string;
public registeredNumber: string;
public inn: string;
@ -9,4 +9,9 @@ export class RussianLegalEntity extends Entity {
public representativePosition: string;
public representativeFullName: string;
public representativeDocument: string;
constructor() {
super();
this.entityType = 'RussianLegalEntity';
}
}

View File

@ -1,5 +1,7 @@
import { ShopLocation } from './shop-location.class';
export class ShopDetail {
public name: string;
public description: string;
public location: string;
public location: ShopLocation;
}

View File

@ -0,0 +1,11 @@
import { ShopLocation } from 'koffing/backend/classes/shop-location.class';
export class ShopLocationUrl extends ShopLocation {
public url: string;
constructor() {
super();
this.locationType = 'ShopLocationUrl';
}
}

View File

@ -0,0 +1,3 @@
export class ShopLocation {
public locationType: string;
}

View File

@ -1,13 +1,21 @@
import { ShopDetail } from './shop-detail.class';
import { CallbackHandler } from './callback-handler';
import { Account } from './account.class';
import { CallbackHandler } from './callback-handler.class';
export class Shop {
public shopID: number;
public id: number;
public isBlocked: boolean;
public isSuspended: boolean;
public categoryRef: number;
public shopDetails: ShopDetail;
public categoryID: number;
public contractID: number;
public payoutAccountID: number;
public payoutToolID: number;
public details: ShopDetail;
public account: Account;
public callbackHandler: CallbackHandler;
constructor() {
this.details = new ShopDetail();
this.account = new Account();
this.callbackHandler = new CallbackHandler();
}
}

View File

@ -7,16 +7,13 @@ import { ConfigService } from './config.service';
@Injectable()
export class AccountService {
constructor(private http: Http, private config: ConfigService) { }
constructor(
private http: Http,
private config: ConfigService
) {}
public getShopAccounts(shopID: string): Promise<any> {
return this.http.get(`${this.config.capiUrl}/processing/shops/${shopID}/accounts`)
.toPromise()
.then(response => response.json());
}
public getShopAccountDetails(shopID: string, accountID: string): Promise<any> {
return this.http.get(`${this.config.capiUrl}/processing/shops/${shopID}/accounts/${accountID}`)
public getAccount(id: string): Promise<any> {
return this.http.get(`${this.config.capiUrl}/processing/accounts/${id}`)
.toPromise()
.then(response => response.json());
}

View File

@ -10,7 +10,7 @@ export class ClaimService {
constructor(private http: Http, private config: ConfigService) { }
public getClaim(queryParams: any): Promise<Claim> {
public getClaim(queryParams: any): Promise<Claim[]> {
let params = new URLSearchParams();
params.set('claimStatus', queryParams.status);
@ -28,7 +28,7 @@ export class ClaimService {
const params = {
reason: revokeDetails.reason
};
return this.http.post(url, params)
return this.http.put(url, params)
.toPromise()
.then(response => response.statusText);
}

View File

@ -4,8 +4,9 @@ import 'rxjs/add/operator/toPromise';
import { ConfigService } from './config.service';
import { Contract } from '../classes/contract.class';
import { Contractor } from '../classes/contractor.class';
import { PayoutAccount } from '../classes/payout-account.class';
import { PayoutTool } from '../classes/payout-tool.class';
import { ContractParams } from 'koffing/backend/classes/contract-params.class';
import { PayoutToolBankAccount } from 'koffing/backend/classes/payout-tool-bank-account.class';
@Injectable()
export class ContractService {
@ -26,18 +27,20 @@ export class ContractService {
.then(response => response.json() as Contract);
}
public createContract(contractor: Contractor): Promise<any> {
return this.http.post(this.contractsUrl, {contractor})
public createContract(request: ContractParams): Promise<any> {
return this.http.post(this.contractsUrl, request)
.toPromise()
.then(response => response.json());
}
public createPayoutAccount(contractID: number, payoutAccount: PayoutAccount): Promise<any> {
const params = {
currency: payoutAccount.currency,
tool: payoutAccount.tool
};
return this.http.post(`${this.contractsUrl}/${contractID}/accounts`, params)
public getPayoutTools(contractID: number): Promise<PayoutTool[]> {
return this.http.get(`${this.contractsUrl}/${contractID}/payout_tools`)
.toPromise()
.then(response => response.json() as PayoutTool[]);
}
public createPayoutTool(contractID: number, payoutTool: PayoutToolBankAccount): Promise<any> {
return this.http.post(`${this.contractsUrl}/${contractID}/payout_tools`, payoutTool)
.toPromise()
.then(response => response.json());
}

View File

@ -11,7 +11,7 @@ export class CustomerService {
constructor(private http: Http, private config: ConfigService) { }
public getPaymentMethod(shopID: string, requestParams: RequestParams): Promise<any> {
public getPaymentMethod(shopID: number, requestParams: RequestParams): Promise<any> {
let params = new URLSearchParams();
let fromTime = moment(requestParams.fromTime).utc().format();
@ -27,14 +27,10 @@ export class CustomerService {
search: params
})
.toPromise()
.then(
response => {
return response.json();
}
);
.then((response) => response.json());
}
public getRate(shopID: string, requestParams: RequestParams): Promise<any> {
public getRate(shopID: number, requestParams: RequestParams): Promise<any> {
let params = new URLSearchParams();
let fromTime = moment(requestParams.fromTime).utc().format();
@ -47,10 +43,6 @@ export class CustomerService {
search: params
})
.toPromise()
.then(
response => {
return response.json();
}
);
.then((response) => response.json());
}
}

View File

@ -14,7 +14,7 @@ export class GeolocationService {
constructor(private http: Http, private config: ConfigService) { }
public getGeoChartData(shopID: string, requestParams: RequestParams): Promise<PaymentGeoStat[]> {
public getGeoChartData(shopID: number, requestParams: RequestParams): Promise<PaymentGeoStat[]> {
const params = new URLSearchParams();
const fromTime = moment(requestParams.fromTime).utc().format();

View File

@ -13,7 +13,7 @@ export class PaymentsService {
constructor(private http: Http, private config: ConfigService) { }
public getRevenueStat(shopID: string, requestParams: RequestParams): Promise<Revenue[]> {
public getRevenueStat(shopID: number, requestParams: RequestParams): Promise<Revenue[]> {
const params = new URLSearchParams();
const fromTime = moment(requestParams.fromTime).utc().format();
@ -31,7 +31,7 @@ export class PaymentsService {
.then(response => response.json());
}
public getConversionStat(shopID: string, requestParams: RequestParams): Promise<Conversion[]> {
public getConversionStat(shopID: number, requestParams: RequestParams): Promise<Conversion[]> {
const params = new URLSearchParams();
const fromTime = moment(requestParams.fromTime).utc().format();

View File

@ -1,30 +0,0 @@
import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
import 'rxjs/add/operator/toPromise';
import { ConfigService } from './config.service';
import { PayoutAccount } from '../classes/payout-account.class';
@Injectable()
export class PayoutAccountService {
private payoutAccountsUrl: string = `${this.config.capiUrl}/processing/payout_accounts`;
constructor(private http: Http, private config: ConfigService) {}
public getPayoutAccounts(): Promise<PayoutAccount[]> {
return this.http.get(this.payoutAccountsUrl)
.toPromise()
.then(response => response.json() as PayoutAccount[]);
}
public createPayoutAccount(payoutAccount: PayoutAccount): Promise<any> {
const params = {
currency: payoutAccount.currency,
tool: payoutAccount.tool
};
return this.http.post(this.payoutAccountsUrl, params)
.toPromise()
.then(response => response.json());
}
}

View File

@ -4,6 +4,7 @@ import 'rxjs/add/operator/toPromise';
import { Shop } from '../classes/shop.class';
import { ConfigService } from './config.service';
import { CreateShopArgs } from 'koffing/backend/classes/create-shop-args.class';
@Injectable()
export class ShopService {
@ -18,28 +19,20 @@ export class ShopService {
.then(response => response.json() as Shop[]);
}
public createShop(args: any): Promise<string> {
const params = {
categoryRef: Number(args.categoryRef),
shopDetails: args.shopDetails,
contractID: Number(args.contractID),
payoutAccountID: Number(args.payoutAccountID),
callbackUrl: args.callbackHandler.url
};
return this.http.post(this.shopsUrl, params)
public getShop(shopID: number): Promise<Shop> {
return this.http.get(`${this.shopsUrl}/${shopID}`)
.toPromise()
.then(response => response.json() as Shop);
}
public createShop(args: CreateShopArgs): Promise<string> {
return this.http.post(this.shopsUrl, args)
.toPromise()
.then(response => response.json());
}
public updateShop(shopID: any, args: any): Promise<string> {
const params = {
categoryRef: Number(args.categoryRef),
shopDetails: args.shopDetails,
contractID: Number(args.contractId),
payoutAccountID: Number(args.payoutAccountId),
callbackUrl: args.callbackHandlerUrl
};
return this.http.post(`${this.shopsUrl}/${shopID}`, params)
public updateShop(shopID: number, args: CreateShopArgs): Promise<string> {
return this.http.post(`${this.shopsUrl}/${shopID}`, args)
.toPromise()
.then(response => response.json());
}

View File

@ -1,9 +1,9 @@
export class SelectItem {
public value: any;
public label: string;
public label: any;
constructor(value: any, label: string) {
constructor(value: any, label: any) {
this.value = value;
this.label = label;
}

View File

@ -37,7 +37,7 @@ export class SelectComponent {
if (value !== this.innerSelectedValue) {
this.innerSelectedValue = value;
this.onChangeCallback(value);
this.onChange.emit();
this.onChange.emit(value);
}
}

View File

@ -1,12 +0,0 @@
import { Contract } from 'koffing/backend/classes/contract.class';
import { PayoutAccount } from 'koffing/backend/classes/payout-account.class';
import { Shop } from 'koffing/backend/backend.module';
export class ShopModificationArgs {
public contracts: Contract[];
public contract: Contract;
public payoutAccount: PayoutAccount;
public shopFields: Shop;
public isNewContract: boolean = false;
public isLoading: boolean = false;
}

View File

@ -3,12 +3,11 @@
h4 Активная заявка
.x_content
div(*ngFor="let set of changeset")
kof-shop-creation(*ngIf="set.modificationType === 'ShopCreation'", [shop]="set.shop")
kof-shop-modification(*ngIf="set.modificationType === 'ShopModificationUnit' && set.details.modificationType === 'ShopUpdate'", [shop]="set.details.details")
kof-shop-account-creation(*ngIf="set.modificationType === 'ShopModificationUnit' && set.details.modificationType === 'ShopAccountCreated'")
kof-shop-suspension(*ngIf="set.modificationType === 'ShopModificationUnit' && set.details.modificationType === 'ShopSuspension'", [suspension]="set.details.details")
kof-contract-creation(*ngIf="set.modificationType === 'ContractCreation'", [contract]="set.contract")
kof-payout-account-creation(*ngIf="set.modificationType === 'PayoutAccountCreation'", [payoutAccount]="set.payoutAccount")
kof-shop-modification(*ngIf="set.partyModificationType === 'ShopModification' && set.shopModificationType === 'ShopUpdate'", [shop]="set.details")
kof-shop-account-creation(*ngIf="set.partyModificationType === 'ShopModification' && set.shopModificationType === 'ShopAccountCreation'")
kof-shop-creation(*ngIf="set.partyModificationType === 'ShopCreation'", [shop]="set.shop")
kof-contract-creation(*ngIf="set.partyModificationType === 'ContractCreation'", [contract]="set.contract")
kof-payout-tool-creation(*ngIf="set.partyModificationType === 'ContractModification' && set.contractModificationType === 'ContractPayoutToolCreation'", [payoutTool]="set.payoutTool")
button.btn.btn-danger.pull-right(data-toggle="modal" data-target=".revoke-modal" data-backdrop="false") Отмена заявки
.modal.fade.revoke-modal(tabindex="-1" role="dialog")

View File

@ -35,9 +35,9 @@ export class ClaimsComponent implements OnInit {
}
private getClaim() {
this.claimService.getClaim({status: 'pending'}).then((claim: Claim) => {
this.claim = claim;
this.changeset = claim.changeset;
this.claimService.getClaim({status: 'pending'}).then((claims: Claim[]) => {
this.claim = claims[0];
this.changeset = this.claim.changeset;
this.showClaimInfo = true;
});
}

View File

@ -7,12 +7,12 @@
kof-modification-detail([displayName]="'Расчетный счет'", [value]="contract.contractor.bankAccount.account")
kof-modification-detail([displayName]="'Корреспондентский счет'", [value]="contract.contractor.bankAccount.bankPostAccount")
kof-modification-detail([displayName]="'БИК'", [value]="contract.contractor.bankAccount.bankBik")
kof-modification-detail([displayName]="'Наименование юр. лица'", [value]="contract.contractor.entity.registeredName")
kof-modification-detail([displayName]="'Номер юр. лица'", [value]="contract.contractor.entity.registeredNumber")
kof-modification-detail([displayName]="'ИНН'", [value]="contract.contractor.entity.inn")
kof-modification-detail([displayName]="'Фактический адрес'", [value]="contract.contractor.entity.actualAddress")
kof-modification-detail([displayName]="'Почтовый адрес'", [value]="contract.contractor.entity.postAddress")
kof-modification-detail([displayName]="'Позиция представителя'", [value]="contract.contractor.entity.representativePosition")
kof-modification-detail([displayName]="'ФИО представителя'", [value]="contract.contractor.entity.representativeFullName")
kof-modification-detail([displayName]="'Документ представителя'", [value]="contract.contractor.entity.representativeDocument")
kof-modification-detail([displayName]="'Наименование юр. лица'", [value]="contract.contractor.legalEntity.registeredName")
kof-modification-detail([displayName]="'Номер юр. лица'", [value]="contract.contractor.legalEntity.registeredNumber")
kof-modification-detail([displayName]="'ИНН'", [value]="contract.contractor.legalEntity.inn")
kof-modification-detail([displayName]="'Фактический адрес'", [value]="contract.contractor.legalEntity.actualAddress")
kof-modification-detail([displayName]="'Почтовый адрес'", [value]="contract.contractor.legalEntity.postAddress")
kof-modification-detail([displayName]="'Позиция представителя'", [value]="contract.contractor.legalEntity.representativePosition")
kof-modification-detail([displayName]="'ФИО представителя'", [value]="contract.contractor.legalEntity.representativeFullName")
kof-modification-detail([displayName]="'Документ представителя'", [value]="contract.contractor.legalEntity.representativeDocument")

View File

@ -1,3 +1,3 @@
dl(*ngIf="value")
dt {{displayName}}
dd {{value}}
dd.modification-detail-value {{value}}

View File

@ -2,7 +2,8 @@ import { Component, Input } from '@angular/core';
@Component({
selector: 'kof-modification-detail',
templateUrl: 'modification-detail.component.pug'
templateUrl: 'modification-detail.component.pug',
styleUrls: [`.modification-detail-value { word-wrap: break-word }`]
})
export class ModificationDetailComponent {

View File

@ -1,19 +0,0 @@
import { Component, Input } from '@angular/core';
import { PayoutAccount } from 'koffing/backend/classes/payout-account.class';
@Component({
selector: 'kof-payout-account-creation',
templateUrl: 'payout-account-creation.component.pug'
})
export class PayoutAccountCreationComponent {
@Input()
public payoutAccount: PayoutAccount;
public showPanel: boolean = false;
public show() {
this.showPanel = !this.showPanel;
}
}

View File

@ -1,11 +1,11 @@
.panel.panel-default
.panel-heading((click)="show()")
a Создание счета
a Создание средства вывода
i.fa.pull-right.custom-chevron([ngClass]="{'fa-chevron-down': showPanel, 'fa-chevron-right': !showPanel}")
.panel-body(*ngIf="showPanel")
kof-modification-detail([displayName]="'Валюта'", [value]="payoutAccount.currency")
kof-modification-detail([displayName]="'Банк'", [value]="payoutAccount.tool.bankAccount.bankName")
kof-modification-detail([displayName]="'Расчетный счет'", [value]="payoutAccount.tool.bankAccount.account")
kof-modification-detail([displayName]="'Корреспондентский счет'", [value]="payoutAccount.tool.bankAccount.bankPostAccount")
kof-modification-detail([displayName]="'БИК'", [value]="payoutAccount.tool.bankAccount.bankBik")
kof-modification-detail([displayName]="'Валюта'", [value]="payoutTool.params.currency")
kof-modification-detail([displayName]="'Банк'", [value]="payoutTool.params.bankAccount.bankName")
kof-modification-detail([displayName]="'Расчетный счет'", [value]="payoutTool.params.bankAccount.account")
kof-modification-detail([displayName]="'Корреспондентский счет'", [value]="payoutTool.params.bankAccount.bankPostAccount")
kof-modification-detail([displayName]="'БИК'", [value]="payoutTool.params.bankAccount.bankBik")

View File

@ -0,0 +1,19 @@
import { Component, Input } from '@angular/core';
import { PayoutTool } from 'koffing/backend/classes/payout-tool.class';
@Component({
selector: 'kof-payout-tool-creation',
templateUrl: 'payout-tool-creation.component.pug'
})
export class PayoutToolCreationComponent {
@Input()
public payoutTool: PayoutTool;
public showPanel: boolean = false;
public show() {
this.showPanel = !this.showPanel;
}
}

View File

@ -1,3 +1,3 @@
.panel.panel-default
.panel-heading
a Создание платежного аккаунта для магазина
a Создание счета для магазина

View File

@ -1,8 +1,13 @@
.panel.panel-default
.panel-heading((click)="show()")
a Создание магазина: {{shop.shopDetails.name}}
a Создание магазина: {{shop.details.name}}
i.fa.pull-right.custom-chevron([ngClass]="{'fa-chevron-down': showPanel, 'fa-chevron-right': !showPanel}")
.panel-body(*ngIf="showPanel")
kof-modification-detail([displayName]="'Название магазина'", [value]="shop.shopDetails.name")
kof-modification-detail([displayName]="'Описание'", [value]="shop.shopDetails.description")
kof-modification-detail([displayName]="'Месторасположение'", [value]="shop.shopDetails.location")
kof-modification-detail([displayName]="'Название магазина'", [value]="shop.details.name")
kof-modification-detail(*ngIf="shop.contractID", [displayName]="'Идентификатор контракта'", [value]="shop.contractID")
kof-modification-detail(*ngIf="shop.details.description", [displayName]="'Описание'", [value]="shop.details.description")
kof-modification-detail(*ngIf="shop.details.location && shop.details.location.url", [displayName]="'Месторасположение'", [value]="shop.details.location.url")
kof-modification-detail(*ngIf="shop.callbackHandler && shop.callbackHandler.url", [displayName]="'Callback handler url'", [value]="shop.callbackHandler.url")
kof-modification-detail(*ngIf="shop.callbackHandler && shop.callbackHandler.publicKey", [displayName]="'Callback handler public key'", [value]="shop.callbackHandler.publicKey")
kof-modification-detail(*ngIf="shop.categoryID", [displayName]="'Идентификатор категории'", [value]="shop.categoryID")
kof-modification-detail(*ngIf="shop.payoutToolID", [displayName]="'Идентификатор средства вывода'", [value]="shop.payoutToolID")

View File

@ -1,8 +1,14 @@
.panel.panel-default
.panel-heading((click)="show()")
a Изменение магазина
a Изменение магазина: {{shop.details.name}}
i.fa.pull-right.custom-chevron([ngClass]="{'fa-chevron-down': showPanel, 'fa-chevron-right': !showPanel}")
.panel-body(*ngIf="showPanel")
kof-modification-detail([displayName]="'Название магазина'", [value]="shop.shopDetails.name")
kof-modification-detail([displayName]="'Описание'", [value]="shop.shopDetails.description")
kof-modification-detail([displayName]="'Месторасположение'", [value]="shop.shopDetails.location")
kof-modification-detail([displayName]="'Название магазина'", [value]="shop.details.name")
kof-modification-detail(*ngIf="shop.contractID", [displayName]="'Идентификатор контракта'", [value]="shop.contractID")
kof-modification-detail(*ngIf="shop.details.description", [displayName]="'Описание'", [value]="shop.details.description")
kof-modification-detail(*ngIf="shop.details.location && shop.details.location.url", [displayName]="'Месторасположение'", [value]="shop.details.location.url")
kof-modification-detail(*ngIf="shop.callbackHandler && shop.callbackHandler.url", [displayName]="'Callback handler url'", [value]="shop.callbackHandler.url")
kof-modification-detail(*ngIf="shop.callbackHandler && shop.callbackHandler.publicKey", [displayName]="'Callback handler public key'", [value]="shop.callbackHandler.publicKey")
kof-modification-detail(*ngIf="shop.categoryID", [displayName]="'Идентификатор категории'", [value]="shop.categoryID")
kof-modification-detail(*ngIf="shop.payoutToolID", [displayName]="'Идентификатор средства вывода'", [value]="shop.payoutToolID")
kof-modification-detail(*ngIf="shop.details.contractID", [displayName]="'Идентификатор контракта'", [value]="shop.details.contractID")

View File

@ -1,87 +1,8 @@
.x_panel.tile
.x_title
h3 Создание нового договора
.x_content
form.form-horizontal.form-label-left.css-form(novalidate, (ngSubmit)="createContract(form)", name="form", #form="ngForm")
h5 Банковские реквизиты
.ln_solid
.form-group
.col-xs-12.col-sm-3
label.text-left Банк
.col-xs-12.col-sm-6
input.form-control(type="text", required, name="bankName", #bankName="ngModel",
[(ngModel)]="newContract.contractor.bankAccount.bankName")
.form-group
.col-xs-12.col-sm-3
label.text-left Расчетный счет
.col-xs-12.col-sm-6
input.form-control(type="text", required, name="bankAccount", #bankAccount="ngModel",
[(ngModel)]="newContract.contractor.bankAccount.account")
.form-group
.col-xs-12.col-sm-3
label.text-left Корреспондентский счет
.col-xs-12.col-sm-6
input.form-control(type="text", required, name="bankPostAccount", #bankPostAccount="ngModel",
[(ngModel)]="newContract.contractor.bankAccount.bankPostAccount")
.form-group
.col-xs-12.col-sm-3
label.text-left БИК
.col-xs-12.col-sm-6
input.form-control(type="text", required, name="bankBik", #bankBik="ngModel",
[(ngModel)]="newContract.contractor.bankAccount.bankBik")
.ln_solid
h5 Реквизиты юр. лица
.ln_solid
.form-group
.col-xs-12.col-sm-3
label.text-left Наименование юр. лица
.col-xs-12.col-sm-6
input.form-control(type="text", required, name="registeredName", #registeredName="ngModel",
[(ngModel)]="newContract.contractor.entity.registeredName")
.form-group
.col-xs-12.col-sm-3
label.text-left Номер юр. лица
.col-xs-12.col-sm-6
input.form-control(type="text", required, name="registeredNumber", #registeredNumber="ngModel",
[(ngModel)]="newContract.contractor.entity.registeredNumber")
.form-group
.col-xs-12.col-sm-3
label.text-left ИНН
.col-xs-12.col-sm-6
input.form-control(type="text", required, name="inn", #inn="ngModel",
[(ngModel)]="newContract.contractor.entity.inn")
.form-group
.col-xs-12.col-sm-3
label.text-left Фактический адрес
.col-xs-12.col-sm-6
input.form-control(type="text", required, name="actualAddress", #actualAddress="ngModel",
[(ngModel)]="newContract.contractor.entity.actualAddress")
.form-group
.col-xs-12.col-sm-3
label.text-left Почтовый адрес
.col-xs-12.col-sm-6
input.form-control(type="text", required, name="postAddress", #postAddress="ngModel",
[(ngModel)]="newContract.contractor.entity.postAddress")
.form-group
.col-xs-12.col-sm-3
label.text-left Позиция представителя
.col-xs-12.col-sm-6
input.form-control(type="text", required, name="representativePosition", #representativePosition="ngModel",
[(ngModel)]="newContract.contractor.entity.representativePosition")
.form-group
.col-xs-12.col-sm-3
label.text-left ФИО представителя
.col-xs-12.col-sm-6
input.form-control(type="text", required, name="representativeFullname", #representativeFullname="ngModel",
[(ngModel)]="newContract.contractor.entity.representativeFullName")
.form-group
.col-xs-12.col-sm-3
label.text-left Документ представителя
.col-xs-12.col-sm-6
input.form-control(type="text", required, name="representativeDocument", #representativeDocument="ngModel",
[(ngModel)]="newContract.contractor.entity.representativeDocument")
.ln_solid
.form-group
.col-xs-12.col-sm-6.col-sm-offset-3
button.btn.btn-primary.pull-right(type="submit", [disabled]="form.invalid || form.pristine || isLoading") Создать договор
a.btn.btn-default(type="reset", [routerLink]="['/management/contracts']") Назад
kof-create-contract((onContractorReady)="onContractorReady($event)")
kof-create-paytool((onPayoutToolReady)="onPayoutToolReady($event)")
.form-group
.col-xs-12.col-sm-6.col-sm-offset-3
button.btn.btn-primary.pull-right(type="button", [disabled]="!isContractorReady || !isPayoutToolReady", (click)="createContract()") Создать договор
a.btn.btn-default(type="reset", (click)="navigateBack()") Назад

View File

@ -1,40 +1,52 @@
import { Component, OnInit } from '@angular/core';
import { Component } from '@angular/core';
import { Router } from '@angular/router';
import { ContractService } from 'koffing/backend/services/contract.service';
import { Contract } from 'koffing/backend/classes/contract.class';
import { Contractor } from 'koffing/backend/classes/contractor.class';
import { BankAccount } from 'koffing/backend/classes/bank-account.class';
import { RussianLegalEntity } from 'koffing/backend/classes/russian-legal-entity.class';
import { PayoutToolBankAccount } from 'koffing/backend/classes/payout-tool-bank-account.class';
import { ContractParams } from 'koffing/backend/classes/contract-params.class';
@Component({
selector: 'kof-contract-create',
templateUrl: 'contract-create.component.pug'
})
export class ContractCreateComponent implements OnInit {
export class ContractCreateComponent {
public newContract: Contract;
public isLoading: boolean = false;
public isContractorReady: boolean = false;
public contractor: Contractor;
public isPayoutToolReady: boolean = false;
public payoutTool: PayoutToolBankAccount;
constructor(
private router: Router,
private contractService: ContractService
) {}
public ngOnInit() {
this.newContract = new Contract();
this.newContract.contractor = new Contractor();
this.newContract.contractor.bankAccount = new BankAccount();
this.newContract.contractor.entity = new RussianLegalEntity();
public onContractorReady(contractor: Contractor) {
this.isContractorReady = true;
this.contractor = contractor;
}
public createContract(form: any) {
if (form.valid) {
public onPayoutToolReady(payoutTool: PayoutToolBankAccount) {
this.isPayoutToolReady = true;
this.payoutTool = payoutTool;
}
public createContract() {
if (this.isContractorReady && this.isContractorReady) {
this.isLoading = true;
this.contractService.createContract(this.newContract.contractor).then(() => {
this.router.navigate(['/management/contracts']);
const contractParams = new ContractParams();
contractParams.contractor = this.contractor;
contractParams.payoutToolParams = this.payoutTool;
this.contractService.createContract(contractParams).then(() => {
this.isLoading = false;
this.navigateBack();
});
}
}
public navigateBack() {
this.router.navigate(['/management/contracts']);
}
}

View File

@ -2,114 +2,103 @@
.x_content
form.form-horizontal.form-label-left.css-form
.form-group
.col-xs-12.col-sm-3
.col-xs-12.col-sm-4
label.text-left Дата заключения
.col-xs-12.col-sm-6
input.form-control(type="text", required, name="concludedAt", #concludedAt="ngModel",
[ngModel]="contract.concludedAt | date:'dd.MM.yy'", [disabled]="true")
.col-xs-12.col-sm-8
input.form-control(type="text", required, name="validSince", #validSince="ngModel",
[ngModel]="contract.validSince | date:'dd.MM.yy'", [disabled]="true")
.form-group
.col-xs-12.col-sm-3
.col-xs-12.col-sm-4
label.text-left Дата истечения
.col-xs-12.col-sm-8
input.form-control(type="text", required, name="validUntil", #validUntil="ngModel",
[ngModel]="contract.validUntil | date:'dd.MM.yy'", [disabled]="true")
.form-group
.col-xs-12.col-sm-4
label.text-left Дата завершения
.col-xs-12.col-sm-6
.col-xs-12.col-sm-8
input.form-control(type="text", required, name="terminatedAt", #terminatedAt="ngModel",
[ngModel]="contract.terminatedAt | date:'dd.MM.yy'", [disabled]="true")
.ln_solid
h5 Банковские реквизиты
.ln_solid
.form-group
.col-xs-12.col-sm-3
.col-xs-12.col-sm-4
label.text-left Наименование банка
.col-xs-12.col-sm-6
.col-xs-12.col-sm-8
input.form-control(type="text", required, name="bankName", #bankName="ngModel",
[ngModel]="contract.contractor.bankAccount.bankName", [disabled]="true")
.form-group
.col-xs-12.col-sm-3
.col-xs-12.col-sm-4
label.text-left Расчетный счет
.col-xs-12.col-sm-6
.col-xs-12.col-sm-8
input.form-control(type="text", required, name="bankAccount", #bankAccount="ngModel",
[ngModel]="contract.contractor.bankAccount.account", [disabled]="true")
.form-group
.col-xs-12.col-sm-3
.col-xs-12.col-sm-4
label.text-left Корреспондентский счет
.col-xs-12.col-sm-6
.col-xs-12.col-sm-8
input.form-control(type="text", required, name="bankPostAccount", #bankPostAccount="ngModel",
[ngModel]="contract.contractor.bankAccount.bankPostAccount", [disabled]="true")
.form-group
.col-xs-12.col-sm-3
.col-xs-12.col-sm-4
label.text-left БИК
.col-xs-12.col-sm-6
.col-xs-12.col-sm-8
input.form-control(type="text", required, name="bankBik", #bankBik="ngModel",
[ngModel]="contract.contractor.bankAccount.bankBik", [disabled]="true")
.ln_solid
h5 Реквизиты юр. лица
.ln_solid
.form-group
.col-xs-12.col-sm-3
.col-xs-12.col-sm-4
label.text-left Наименование юр. лица
.col-xs-12.col-sm-6
.col-xs-12.col-sm-8
input.form-control(type="text", required, name="registeredName", #registeredName="ngModel",
[ngModel]="contract.contractor.entity.registeredName", [disabled]="true")
[ngModel]="contract.contractor.legalEntity.registeredName", [disabled]="true")
.form-group
.col-xs-12.col-sm-3
.col-xs-12.col-sm-4
label.text-left ОГРН
.col-xs-12.col-sm-6
.col-xs-12.col-sm-8
input.form-control(type="text", required, name="registeredNumber", #registeredNumber="ngModel",
[ngModel]="contract.contractor.entity.registeredNumber", [disabled]="true")
[ngModel]="contract.contractor.legalEntity.registeredNumber", [disabled]="true")
.form-group
.col-xs-12.col-sm-3
.col-xs-12.col-sm-4
label.text-left ИНН
.col-xs-12.col-sm-6
.col-xs-12.col-sm-8
input.form-control(type="text", required, name="inn", #inn="ngModel",
[ngModel]="contract.contractor.entity.inn", [disabled]="true")
[ngModel]="contract.contractor.legalEntity.inn", [disabled]="true")
.form-group
.col-xs-12.col-sm-3
.col-xs-12.col-sm-4
label.text-left Фактический адрес
.col-xs-12.col-sm-6
.col-xs-12.col-sm-8
input.form-control(type="text", required, name="actualAddress", #actualAddress="ngModel",
[ngModel]="contract.contractor.entity.actualAddress", [disabled]="true")
[ngModel]="contract.contractor.legalEntity.actualAddress", [disabled]="true")
.form-group
.col-xs-12.col-sm-3
.col-xs-12.col-sm-4
label.text-left Почтовый адрес
.col-xs-12.col-sm-6
.col-xs-12.col-sm-8
input.form-control(type="text", required, name="postAddress", #postAddress="ngModel",
[ngModel]="contract.contractor.entity.postAddress", [disabled]="true")
[ngModel]="contract.contractor.legalEntity.postAddress", [disabled]="true")
.form-group
.col-xs-12.col-sm-3
.col-xs-12.col-sm-4
label.text-left Должность ЕИО/представителя
.col-xs-12.col-sm-6
.col-xs-12.col-sm-8
input.form-control(type="text", required, name="representativePosition", #representativePosition="ngModel",
[ngModel]="contract.contractor.entity.representativePosition", [disabled]="true")
[ngModel]="contract.contractor.legalEntity.representativePosition", [disabled]="true")
.form-group
.col-xs-12.col-sm-3
.col-xs-12.col-sm-4
label.text-left ФИО ЕИО/представителя
.col-xs-12.col-sm-6
.col-xs-12.col-sm-8
input.form-control(type="text", required, name="representativeFullname", #representativeFullname="ngModel",
[ngModel]="contract.contractor.entity.representativeFullName", [disabled]="true")
[ngModel]="contract.contractor.legalEntity.representativeFullName", [disabled]="true")
.form-group
.col-xs-12.col-sm-3
.col-xs-12.col-sm-4
label.text-left Документ ЕИО/представителя
.col-xs-12.col-sm-6
.col-xs-12.col-sm-8
input.form-control(type="text", required, name="representativeDocument", #representativeDocument="ngModel",
[ngModel]="contract.contractor.entity.representativeDocument", [disabled]="true")
.container(*ngIf="showAccounts === true")
[ngModel]="contract.contractor.legalEntity.representativeDocument", [disabled]="true")
.container(*ngIf="isShowPayoutTools")
.ln_solid
h5 Счета
.ln_solid
table.table.table-striped(*ngIf="contract.payoutAccounts.length")
thead
tr
th ID счета
th Валюта
th Банк
th Расчетный счет
tbody(*ngFor="let payoutAccount of contract.payoutAccounts; let index = index")
tr((click)="selectedIndex = index")
td {{payoutAccount.id}}
td {{payoutAccount.currency}}
td {{payoutAccount.tool.bankAccount.bankName}}
td {{payoutAccount.tool.bankAccount.account}}
tr(*ngIf="index === selectedIndex")
td(colspan=4)
kof-payout-account-view([payoutAccount]="payoutAccount")
span(*ngIf="!contract.payoutAccounts.length") Нет привязанных счетов
a.btn.btn-primary.pull-right([routerLink]="['/management/contracts', contract.id, 'payout-account', 'create']") Добавить счет
kof-payout-tools([contractID]="contract.id")

View File

@ -1,16 +1,31 @@
import { Component, Input } from '@angular/core';
import { Component, Input, OnInit } from '@angular/core';
import { Contract } from 'koffing/backend/classes/contract.class';
import { Contractor } from 'koffing/backend/classes/contractor.class';
import { BankAccount } from 'koffing/backend/classes/bank-account.class';
import { RussianLegalEntity } from 'koffing/backend/classes/russian-legal-entity.class';
@Component({
selector: 'kof-contract-view',
templateUrl: 'contract-view.component.pug'
})
export class ContractViewComponent {
export class ContractViewComponent implements OnInit {
@Input()
public showAccounts: boolean = true;
public isShowPayoutTools: boolean = true;
@Input()
public contract: Contract;
public ngOnInit() {
if (!this.contract.contractor) {
this.contract.contractor = new Contractor();
}
if (!this.contract.contractor.bankAccount) {
this.contract.contractor.bankAccount = new BankAccount();
}
if (!this.contract.contractor.legalEntity) {
this.contract.contractor.legalEntity = new RussianLegalEntity();
}
}
}

View File

@ -5,19 +5,19 @@
tr
th ID договора
th Дата заключения
th.hidden-xs Дата завершения
th.hidden-xs Дата истечения
th.hidden-xs Название организации
th ИНН организации
th Статус
tbody(*ngFor="let contract of contracts; let index = index")
tr((click)="selectedIndex = index")
tbody(*ngFor="let contract of contracts")
tr((click)="selectContract(contract)")
td {{contract.id}}
td {{contract.concludedAt | date:"dd.MM.yyyy"}}
td.hidden-xs {{contract.terminatedAt | date:"dd.MM.yyyy"}}
td.hidden-xs {{contract.contractor.entity.registeredName}}
td {{contract.contractor.entity.inn}}
td {{!!contract.terminatedAt ? 'завершен' : !contract.concludedAt ? 'в&nbsp;обработке' : 'активен'}}
tr(*ngIf="index === selectedIndex")
td {{contract.validSince | date:"dd.MM.yyyy"}}
td.hidden-xs {{contract.validUntil | date:"dd.MM.yyyy"}}
td.hidden-xs {{(contract.contractor && contract.contractor.legalEntity) ? contract.contractor.legalEntity.registeredName : null}}
td {{(contract.contractor && contract.contractor.legalEntity) ? contract.contractor.legalEntity.inn : null}}
td {{!!contract.terminatedAt ? 'завершен' : !contract.validSince ? 'в&nbsp;обработке' : 'активен'}}
tr(*ngIf="contract === selectedContract")
td(colspan=6)
kof-contract-view([contract]="contract")
span(*ngIf="!contracts.length") Список договоров пуст

View File

@ -1,8 +1,5 @@
import { Component, OnInit } from '@angular/core';
import * as _ from 'lodash';
import { ClaimService } from 'koffing/backend/services/claim.service';
import { Claim } from 'koffing/backend/classes/claim.class';
import { ContractService } from 'koffing/backend/services/contract.service';
import { Contract } from 'koffing/backend/classes/contract.class';
@ -12,41 +9,26 @@ import { Contract } from 'koffing/backend/classes/contract.class';
export class ContractsComponent implements OnInit {
public contracts: Contract[] = [];
public isLoading: boolean;
public isLoading: boolean = false;
public selectedContract: Contract;
constructor(
private claimService: ClaimService,
private contractService: ContractService
) {}
public ngOnInit() {
this.isLoading = true;
this.getContracts().then((contracts: Contract[]) => {
this.contractService.getContracts().then((contracts: Contract[]) => {
this.contracts = contracts;
this.isLoading = false;
});
}
private loadContracts(): Promise<Contract[]> {
return this.contractService.getContracts().then((contracts: Contract[]) => contracts);
}
private loadContractsClaimed(): Promise<Contract[]> {
return this.claimService.getClaim({status: 'pending'}).then((claim: Claim) => {
return _
.chain(claim.changeset)
.filter((changeSet) => changeSet.modificationType === 'ContractCreation')
.map((changeSet) => changeSet.contract)
.value();
});
}
private getContracts(): Promise<Contract[]> {
return Promise.all([
this.loadContracts(),
this.loadContractsClaimed()
]).then((contracts: any) => {
return _.reduce(contracts, (current: Contract[], next: Contract[]) => _.concat(current, next));
});
public selectContract(contract: Contract) {
if (this.selectedContract === contract) {
this.selectedContract = new Contract();
} else {
this.selectedContract = contract;
}
}
}

View File

@ -1,13 +0,0 @@
import { Component, Input } from '@angular/core';
import { PayoutAccount } from 'koffing/backend/classes/payout-account.class';
@Component({
selector: 'kof-payout-account-view',
templateUrl: 'payout-account-view.component.pug'
})
export class PayoutAccountViewComponent {
@Input()
public payoutAccount: PayoutAccount;
}

View File

@ -2,39 +2,39 @@
.x_title
h3 Создание нового счета
.x_content
form.form-horizontal.form-label-left.css-form(novalidate, (ngSubmit)="createPayoutAccount(form)", name="form", #form="ngForm")
form.form-horizontal.form-label-left.css-form(novalidate, (ngSubmit)="createPayoutTool(form)", name="form", #form="ngForm")
.form-group
.col-xs-12.col-sm-3
label.text-left Валюта
.col-xs-12.col-sm-6
input.form-control(type="text", required, name="currency", #currency="ngModel",
[(ngModel)]="newPayoutAccount.currency")
[(ngModel)]="payoutTool.currency")
.form-group
.col-xs-12.col-sm-3
label.text-left Банк
.col-xs-12.col-sm-6
input.form-control(type="text", required, name="bankName", #bankName="ngModel",
[(ngModel)]="newPayoutAccount.tool.bankAccount.bankName")
[(ngModel)]="payoutTool.bankAccount.bankName")
.form-group
.col-xs-12.col-sm-3
label.text-left Расчетный счет
.col-xs-12.col-sm-6
input.form-control(type="text", required, name="bankAccount", #bankAccount="ngModel",
[(ngModel)]="newPayoutAccount.tool.bankAccount.account")
[(ngModel)]="payoutTool.bankAccount.account")
.form-group
.col-xs-12.col-sm-3
label.text-left Корреспондентский счет
.col-xs-12.col-sm-6
input.form-control(type="text", required, name="bankPostAccount", #bankPostAccount="ngModel",
[(ngModel)]="newPayoutAccount.tool.bankAccount.bankPostAccount")
[(ngModel)]="payoutTool.bankAccount.bankPostAccount")
.form-group
.col-xs-12.col-sm-3
label.text-left БИК
.col-xs-12.col-sm-6
input.form-control(type="text", required, name="bankBik", #bankBik="ngModel",
[(ngModel)]="newPayoutAccount.tool.bankAccount.bankBik")
[(ngModel)]="payoutTool.bankAccount.bankBik")
.ln_solid
.form-group
.col-xs-12.col-sm-6.col-sm-offset-3
button.btn.btn-primary.pull-right(type="submit", [disabled]="form.invalid || form.pristine || isLoading") Добавить счет
a.btn.btn-default(type="reset", [routerLink]="['/management/contracts']") Назад
a.btn.btn-default(type="reset", (click)="navigateBack()") Назад

View File

@ -2,21 +2,20 @@ import { Component, OnInit } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';
import { ContractService } from 'koffing/backend/services/contract.service';
import { PayoutAccount } from 'koffing/backend/classes/payout-account.class';
import { PayoutToolBankAccount } from 'koffing/backend/classes/payout-tool-bank-account.class';
import { BankAccount } from 'koffing/backend/classes/bank-account.class';
@Component({
selector: 'kof-payout-account-create',
templateUrl: 'payout-account-create.component.pug'
selector: 'kof-payout-tool-create',
templateUrl: 'payout-tool-create.component.pug'
})
export class PayoutAccountCreateComponent implements OnInit {
export class PayoutToolCreateComponent implements OnInit {
public newPayoutAccount: PayoutAccount;
public contractID: number = Number(this.route.snapshot.params['contractID']);
public shopEditID: number = Number(this.route.snapshot.params['shopID']);
public payoutTool: PayoutToolBankAccount;
public isLoading: boolean = false;
private contractID: number = Number(this.route.snapshot.params['contractID']);
constructor(
private route: ActivatedRoute,
private router: Router,
@ -24,19 +23,23 @@ export class PayoutAccountCreateComponent implements OnInit {
) {}
public ngOnInit() {
this.newPayoutAccount = new PayoutAccount();
const payoutToolBankAccount = new PayoutToolBankAccount();
payoutToolBankAccount.bankAccount = new BankAccount();
this.newPayoutAccount.tool = payoutToolBankAccount;
this.payoutTool = this.getInstance();
}
public createPayoutAccount(form: any) {
public createPayoutTool(form: any) {
if (form.valid) {
this.isLoading = true;
this.contractService.createPayoutAccount(this.contractID, this.newPayoutAccount).then(() => {
this.router.navigate(['/management/contracts']);
this.contractService.createPayoutTool(this.contractID, this.payoutTool).then(() => {
this.isLoading = false;
this.router.navigate(['/management/contracts']);
});
}
}
private getInstance() {
const bankAccount = new BankAccount();
const instance = new PayoutToolBankAccount();
instance.bankAccount = bankAccount;
return instance;
}
}

View File

@ -2,32 +2,32 @@
.x_content
form.form-horizontal.form-label-left.css-form
.form-group
.col-xs-12.col-sm-3
.col-xs-12.col-sm-4
label.text-left Валюта
.col-xs-12.col-sm-6
.col-xs-12.col-sm-8
input.form-control(type="text", required, name="currency", #currency="ngModel",
[(ngModel)]="payoutAccount.currency", [disabled]="true")
[(ngModel)]="payoutTool.params.currency", [disabled]="true")
.form-group
.col-xs-12.col-sm-3
.col-xs-12.col-sm-4
label.text-left Наименование банка
.col-xs-12.col-sm-6
.col-xs-12.col-sm-8
input.form-control(type="text", required, name="bankName", #bankName="ngModel",
[(ngModel)]="payoutAccount.tool.bankAccount.bankName", [disabled]="true")
[(ngModel)]="payoutTool.params.bankAccount.bankName", [disabled]="true")
.form-group
.col-xs-12.col-sm-3
.col-xs-12.col-sm-4
label.text-left Расчетный счет
.col-xs-12.col-sm-6
.col-xs-12.col-sm-8
input.form-control(type="text", required, name="bankAccount", #bankAccount="ngModel",
[(ngModel)]="payoutAccount.tool.bankAccount.account", [disabled]="true")
[(ngModel)]="payoutTool.params.bankAccount.account", [disabled]="true")
.form-group
.col-xs-12.col-sm-3
.col-xs-12.col-sm-4
label.text-left Корреспондентский счет
.col-xs-12.col-sm-6
.col-xs-12.col-sm-8
input.form-control(type="text", required, name="bankPostAccount", #bankPostAccount="ngModel",
[(ngModel)]="payoutAccount.tool.bankAccount.bankPostAccount", [disabled]="true")
[(ngModel)]="payoutTool.params.bankAccount.bankPostAccount", [disabled]="true")
.form-group
.col-xs-12.col-sm-3
.col-xs-12.col-sm-4
label.text-left БИК
.col-xs-12.col-sm-6
.col-xs-12.col-sm-8
input.form-control(type="text", required, name="bankBik", #bankBik="ngModel",
[(ngModel)]="payoutAccount.tool.bankAccount.bankBik", [disabled]="true")
[(ngModel)]="payoutTool.params.bankAccount.bankBik", [disabled]="true")

View File

@ -0,0 +1,13 @@
import { Component, Input } from '@angular/core';
import { PayoutTool } from 'koffing/backend/classes/payout-tool.class';
@Component({
selector: 'kof-payout-tool-view',
templateUrl: 'payout-tool-view.component.pug'
})
export class PayoutToolViewComponent {
@Input()
public payoutTool: PayoutTool;
}

View File

@ -0,0 +1,19 @@
kof-loading([isLoading]="isLoading")
table.table.table-striped(*ngIf="payoutTools.length")
thead
tr
th ID счета
th Валюта
th Банк
th Расчетный счет
tbody(*ngFor="let payoutTool of payoutTools")
tr((click)="selectPayoutTool(payoutTool)")
td {{payoutTool.id}}
td {{payoutTool.params.currency}}
td {{payoutTool.params.bankAccount.bankName}}
td {{payoutTool.params.bankAccount.account}}
tr(*ngIf="payoutTool === selectedPayoutTool")
td(colspan=4)
kof-payout-tool-view([payoutTool]="payoutTool")
span(*ngIf="!payoutTools.length") Нет привязанных счетов
a.btn.btn-primary.pull-right([routerLink]="['/management/contracts', contractID, 'payout-tool', 'create']") Добавить счет

View File

@ -0,0 +1,38 @@
import { Component, Input, OnInit } from '@angular/core';
import { ContractService } from 'koffing/backend/services/contract.service';
import { PayoutTool } from 'koffing/backend/classes/payout-tool.class';
@Component({
selector: 'kof-payout-tools',
templateUrl: 'payout-tools.component.pug'
})
export class PayoutToolsComponent implements OnInit {
@Input()
public contractID: number;
public payoutTools: PayoutTool[] = [];
public isLoading: boolean = false;
public selectedPayoutTool: PayoutTool;
constructor(
private contractService: ContractService
) {}
public ngOnInit() {
this.isLoading = true;
this.contractService.getPayoutTools(this.contractID).then((payoutTools: PayoutTool[]) => {
this.payoutTools = payoutTools;
this.isLoading = false;
});
}
public selectPayoutTool(payoutTool: PayoutTool) {
if (this.selectedPayoutTool === payoutTool) {
this.selectedPayoutTool = new PayoutTool();
} else {
this.selectedPayoutTool = payoutTool;
}
}
}

View File

@ -9,32 +9,29 @@
li
a([ngClass]="{'done': currentStep > contractStep, 'selected': currentStep === contractStep}")
span.step_no 1
span.step_descr Выбор контракта
span.step_descr Контракт
li
a([ngClass]="{'disabled': currentStep < accountStep, 'done': currentStep > accountStep, 'selected': currentStep === accountStep}")
a([ngClass]="{'disabled': currentStep < paytoolStep, 'done': currentStep > paytoolStep, 'selected': currentStep === paytoolStep}")
span.step_no 2
span.step_descr Выбор счета
span.step_descr Средство вывода
li
a([ngClass]="{'disabled': currentStep < shopDetailsStep, 'done': currentStep > shopDetailsStep, 'selected': currentStep === shopDetailsStep}")
span.step_no 3
span.step_descr Данные магазина
kof-loading([isLoading]="wizardArgs.isLoading")
kof-selection-contract(
*ngIf="currentStep === contractStep",
(steppedBackward)="returnToManagement()",
(steppedForward)="goToStep(accountStep)",
[args]="wizardArgs"
)
kof-selection-account(
*ngIf="currentStep === accountStep",
(steppedBackward)="returnToManagement()",
(steppedForward)="goToStep(shopDetailsStep)",
[args]="wizardArgs"
)
kof-selection-shop-fields(
*ngIf="currentStep === shopDetailsStep",
(steppedBackward)="returnToManagement()",
(steppedForward)="finishWizard()",
[args]="wizardArgs",
[showFinishButton]="true"
)
kof-selection-contract(
*ngIf="currentStep === contractStep",
(steppedBackward)="returnToManagement()",
(steppedForward)="goToPaytoolStep($event)"
)
kof-selection-paytool(
*ngIf="currentStep === paytoolStep",
(steppedBackward)="returnToManagement()",
(steppedForward)="goToShopDetailsStep($event)",
[contractDecision]="contractDecision"
)
kof-selection-shop-fields(
*ngIf="currentStep === shopDetailsStep",
(steppedBackward)="returnToManagement()",
(onCreated)="finishWizard()",
[payoutToolDecision]="payoutToolDecision",
)

View File

@ -1,69 +1,43 @@
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import * as _ from 'lodash';
import { ContractService } from 'koffing/backend/services/contract.service';
import { ShopModificationArgs } from 'koffing/management/management.module';
import { ShopService } from 'koffing/backend/services/shop.service';
import { ContractDecision } from 'koffing/management/components/management-container/shops/create-shop-wizard/selection-contract/contract-decision.class';
import { PaytoolDecision } from 'koffing/management/components/management-container/shops/create-shop-wizard/selection-paytool/paytool-decision.class';
@Component({
templateUrl: './create-shop-wizard.component.pug'
templateUrl: 'create-shop-wizard.component.pug'
})
export class CreateShopWizardComponent implements OnInit {
public currentStep: number;
public contractStep: number = 1;
public accountStep: number = 2;
public paytoolStep: number = 2;
public shopDetailsStep: number = 3;
public wizardArgs: ShopModificationArgs = new ShopModificationArgs();
constructor(
private router: Router,
private contractService: ContractService,
private shopService: ShopService
) { }
public contractDecision: ContractDecision;
public payoutToolDecision: PaytoolDecision;
constructor(private router: Router) { }
public ngOnInit() {
this.currentStep = this.contractStep;
}
public returnToManagement() {
this.router.navigate(['/management']);
}
public goToStep(step: number) {
this.currentStep = step;
public goToPaytoolStep(contractDecision: ContractDecision) {
this.currentStep = this.paytoolStep;
this.contractDecision = contractDecision;
}
public goToShopDetailsStep(payoutToolDecision: PaytoolDecision) {
this.payoutToolDecision = payoutToolDecision;
this.currentStep = this.shopDetailsStep;
}
public finishWizard() {
this.createShop().then(() => {
this.returnToManagement();
});
}
public ngOnInit() {
this.wizardArgs.isLoading = false;
this.loadContracts();
this.goToStep(this.contractStep);
}
private loadContracts() {
this.wizardArgs.isLoading = true;
this.contractService.getContracts().then((contracts) => {
this.wizardArgs.contracts = contracts;
this.wizardArgs.isLoading = false;
});
}
private createShop(): Promise<any> {
this.wizardArgs.isLoading = true;
return new Promise((resolve) => {
this.shopService.createShop(_.merge(
this.wizardArgs.shopFields,
{ contractID: this.wizardArgs.contract.id },
{ payoutAccountID: this.wizardArgs.payoutAccount.id }
)).then(() => {
this.wizardArgs.isLoading = false;
resolve();
});
});
this.returnToManagement();
}
}

View File

@ -0,0 +1,11 @@
import { Contractor } from 'koffing/backend/classes/contractor.class';
export class ContractDecision {
public contractID: number;
public contractor: Contractor;
constructor(contractID?: number, contractor?: Contractor) {
this.contractID = contractID;
this.contractor = contractor;
}
}

View File

@ -10,28 +10,28 @@
label.text-left Расчетный счет
.col-xs-12.col-sm-6
input.form-control(type="text", required, name="bank_account",
[(ngModel)]="newContract.contractor.bankAccount.account", #bank_account="ngModel",
[(ngModel)]="contractor.bankAccount.account", #bank_account="ngModel",
(keyup)="checkForm(form)")
.form-group([ngClass]="{'has-error': hasError(bank_name)}")
.col-xs-12.col-sm-3
label.text-left Наименование банка
.col-xs-12.col-sm-6
input.form-control(type="text", required, name="bank_name",
[(ngModel)]="newContract.contractor.bankAccount.bankName", #bank_name="ngModel",
[(ngModel)]="contractor.bankAccount.bankName", #bank_name="ngModel",
(keyup)="checkForm(form)")
.form-group([ngClass]="{'has-error': hasError(bank_post_account)}")
.col-xs-12.col-sm-3
label.text-left Корреспондентский счет
.col-xs-12.col-sm-6
input.form-control(type="text", required, name="bank_post_account",
[(ngModel)]="newContract.contractor.bankAccount.bankPostAccount", #bank_post_account="ngModel",
[(ngModel)]="contractor.bankAccount.bankPostAccount", #bank_post_account="ngModel",
(keyup)="checkForm(form)")
.form-group([ngClass]="{'has-error': hasError(bank_bik)}")
.col-xs-12.col-sm-3
label.text-left БИК
.col-xs-12.col-sm-6
input.form-control(type="text", required, name="bank_bik",
[(ngModel)]="newContract.contractor.bankAccount.bankBik", #bank_bik="ngModel",
[(ngModel)]="contractor.bankAccount.bankBik", #bank_bik="ngModel",
(keyup)="checkForm(form)")
.ln_solid
h5 Реквизиты юр. лица
@ -41,55 +41,55 @@
label.text-left Наименование юр. лица
.col-xs-12.col-sm-6
input.form-control(type="text", name="entity_registered_name", required,
[(ngModel)]="newContract.contractor.entity.registeredName", #entity_registered_name="ngModel",
[(ngModel)]="contractor.legalEntity.registeredName", #entity_registered_name="ngModel",
(keyup)="checkForm(form)")
.form-group([ngClass]="{'has-error': hasError(entity_registered_number)}")
.col-xs-12.col-sm-3
label.text-left ОГРН
.col-xs-12.col-sm-6
input.form-control(type="text", name="entity_registered_number", required,
[(ngModel)]="newContract.contractor.entity.registeredNumber", #entity_registered_number="ngModel",
[(ngModel)]="contractor.legalEntity.registeredNumber", #entity_registered_number="ngModel",
(keyup)="checkForm(form)")
.form-group([ngClass]="{'has-error': hasError(entity_inn)}")
.col-xs-12.col-sm-3
label.text-left ИНН
.col-xs-12.col-sm-6
input.form-control(type="text", name="entity_inn", required,
[(ngModel)]="newContract.contractor.entity.inn", #entity_inn="ngModel",
[(ngModel)]="contractor.legalEntity.inn", #entity_inn="ngModel",
(keyup)="checkForm(form)")
.form-group([ngClass]="{'has-error': hasError(entity_actual_address)}")
.col-xs-12.col-sm-3
label.text-left Фактический адрес
.col-xs-12.col-sm-6
input.form-control(type="text", name="entity_actual_address", required,
[(ngModel)]="newContract.contractor.entity.actualAddress", #entity_actual_address="ngModel",
[(ngModel)]="contractor.legalEntity.actualAddress", #entity_actual_address="ngModel",
(keyup)="checkForm(form)")
.form-group([ngClass]="{'has-error': hasError(entity_post_address)}")
.col-xs-12.col-sm-3
label.text-left Почтовый адрес
.col-xs-12.col-sm-6
input.form-control(type="text", name="entity_post_address", required,
[(ngModel)]="newContract.contractor.entity.postAddress", #entity_post_address="ngModel",
[(ngModel)]="contractor.legalEntity.postAddress", #entity_post_address="ngModel",
(keyup)="checkForm(form)")
.form-group([ngClass]="{'has-error': hasError(entity_representative_position)}")
.col-xs-12.col-sm-3
label.text-left Должность ЕИО/представителя
.col-xs-12.col-sm-6
input.form-control(type="text", name="entity_representative_position", required,
[(ngModel)]="newContract.contractor.entity.representativePosition", #entity_representative_position="ngModel",
[(ngModel)]="contractor.legalEntity.representativePosition", #entity_representative_position="ngModel",
(keyup)="checkForm(form)")
.form-group([ngClass]="{'has-error': hasError(entity_representative_fullname)}")
.col-xs-12.col-sm-3
label.text-left ФИО ЕИО/представителя
.col-xs-12.col-sm-6
input.form-control(type="text", name="entity_representative_fullname", required,
[(ngModel)]="newContract.contractor.entity.representativeFullName", #entity_representative_fullname="ngModel",
[(ngModel)]="contractor.legalEntity.representativeFullName", #entity_representative_fullname="ngModel",
(keyup)="checkForm(form)")
.form-group([ngClass]="{'has-error': hasError(entity_representative_document)}")
.col-xs-12.col-sm-3
label.text-left Документ ЕИО/представителя
.col-xs-12.col-sm-6
input.form-control(type="text", name="entity_representative_document", required,
[(ngModel)]="newContract.contractor.entity.representativeDocument", #entity_representative_document="ngModel",
[(ngModel)]="contractor.legalEntity.representativeDocument", #entity_representative_document="ngModel",
(keyup)="checkForm(form)")
.ln_solid

View File

@ -0,0 +1,40 @@
import { Component, Output, EventEmitter, OnInit } from '@angular/core';
import { Contractor } from 'koffing/backend/classes/contractor.class';
import { BankAccount } from 'koffing/backend/classes/bank-account.class';
import { RussianLegalEntity } from 'koffing/backend/classes/russian-legal-entity.class';
@Component({
selector: 'kof-create-contract',
templateUrl: 'create-contract.component.pug'
})
export class CreateContractComponent implements OnInit {
@Output()
public onContractorReady = new EventEmitter();
public contractor: Contractor;
public ngOnInit() {
this.contractor = this.createInstance();
}
public checkForm(form: any) {
if (form.valid) {
this.onContractorReady.emit(this.contractor);
}
}
public hasError(field: any): boolean {
return field.dirty && field.invalid;
}
private createInstance() {
const bankAccountArgs = new BankAccount();
const entityArgs = new RussianLegalEntity();
const instance = new Contractor();
instance.bankAccount = bankAccountArgs;
instance.legalEntity = entityArgs;
return instance;
}
}

View File

@ -0,0 +1,86 @@
.x_panel.tile
.x_title
h4 Выбор существующего контракта
kof-loading([isLoading]="isLoading")
.x_content
.tile
kof-select.col-xs-6(*ngIf="selectableItems.length", [(ngModel)]="selectedContractId", [items]="selectableItems", (onChange)="selectContract()", [modelOptions]="{standalone: true}", name='selectedContract')
.ln_solid
form.form-horizontal.form-label-left.css-form(*ngIf="selectedContractId !== undefined", novalidate, name="form", #form="ngForm")
h5 Банковские реквизиты
.ln_solid
.form-group
.col-xs-12.col-sm-3
label.text-left Расчетный счет
.col-xs-12.col-sm-6
input.form-control(disabled, type="text", required, name="bank_account",
[(ngModel)]="selectedContract.contractor.bankAccount.account", #bank_account="ngModel")
.form-group
.col-xs-12.col-sm-3
label.text-left Наименование банка
.col-xs-12.col-sm-6
input.form-control(disabled, type="text", required, name="bank_name",
[(ngModel)]="selectedContract.contractor.bankAccount.bankName", #bank_name="ngModel")
.form-group
.col-xs-12.col-sm-3
label.text-left Корреспондентский счет
.col-xs-12.col-sm-6
input.form-control(disabled, type="text", required, name="bank_post_account",
[(ngModel)]="selectedContract.contractor.bankAccount.bankPostAccount", #bank_post_account="ngModel")
.form-group
.col-xs-12.col-sm-3
label.text-left БИК
.col-xs-12.col-sm-6
input.form-control(disabled, type="text", required, name="bank_bik",
[(ngModel)]="selectedContract.contractor.bankAccount.bankBik", #bank_bik="ngModel")
.ln_solid
h5 Реквизиты юр. лица
.ln_solid
.form-group
.col-xs-12.col-sm-3
label.text-left Наименование юр. лица
.col-xs-12.col-sm-6
input.form-control(disabled, type="text", name="entity_registered_name", required,
[(ngModel)]="selectedContract.contractor.legalEntity.registeredName", #entity_registered_name="ngModel")
.form-group
.col-xs-12.col-sm-3
label.text-left ОГРН
.col-xs-12.col-sm-6
input.form-control(disabled, type="text", name="entity_registered_number", required,
[(ngModel)]="selectedContract.contractor.legalEntity.registeredNumber", #entity_registered_number="ngModel")
.form-group
.col-xs-12.col-sm-3
label.text-left ИНН
.col-xs-12.col-sm-6
input.form-control(disabled, type="text", name="entity_inn", required,
[(ngModel)]="selectedContract.contractor.legalEntity.inn", #entity_inn="ngModel")
.form-group
.col-xs-12.col-sm-3
label.text-left Фактический адрес
.col-xs-12.col-sm-6
input.form-control(disabled, type="text", name="entity_actual_address", required,
[(ngModel)]="selectedContract.contractor.legalEntity.actualAddress", #entity_actual_address="ngModel")
.form-group
.col-xs-12.col-sm-3
label.text-left Почтовый адрес
.col-xs-12.col-sm-6
input.form-control(disabled, type="text", name="entity_post_address", required,
[(ngModel)]="selectedContract.contractor.legalEntity.postAddress", #entity_post_address="ngModel")
.form-group
.col-xs-12.col-sm-3
label.text-left Должность ЕИО/представителя
.col-xs-12.col-sm-6
input.form-control(disabled, type="text", name="entity_representative_position", required,
[(ngModel)]="selectedContract.contractor.legalEntity.representativePosition", #entity_representative_position="ngModel")
.form-group
.col-xs-12.col-sm-3
label.text-left ФИО ЕИО/представителя
.col-xs-12.col-sm-6
input.form-control(disabled, type="text", name="entity_representative_fullname", required,
[(ngModel)]="selectedContract.contractor.legalEntity.representativeFullName", #entity_representative_fullname="ngModel")
.form-group
.col-xs-12.col-sm-3
label.text-left Документ ЕИО/представителя
.col-xs-12.col-sm-6
input.form-control(disabled, type="text", name="entity_representative_document", required,
[(ngModel)]="selectedContract.contractor.legalEntity.representativeDocument", #entity_representative_document="ngModel")

View File

@ -0,0 +1,49 @@
import { Component, OnInit, Output, EventEmitter } from '@angular/core';
import * as _ from 'lodash';
import { SelectItem } from 'koffing/common/common.module';
import { Contract } from 'koffing/backend/classes/contract.class';
import { ContractService } from 'koffing/backend/services/contract.service';
@Component({
selector: 'kof-select-contract',
templateUrl: 'select-contract.component.pug'
})
export class SelectContractComponent implements OnInit {
@Output()
public onContractSelected = new EventEmitter();
public selectableItems: SelectItem[] = [];
public selectedContractId: number;
public contracts: Contract[];
public selectedContract: Contract;
public isLoading: boolean = true;
constructor(private contractService: ContractService) { }
public ngOnInit() {
this.contractService.getContracts().then((contracts) => {
this.isLoading = false;
this.contracts = contracts;
this.selectableItems = this.prepareSelectableItems(contracts);
});
}
public selectContract() {
this.selectedContract = this.findSelectedContract(this.contracts, this.selectedContractId);
this.onContractSelected.emit(_.toNumber(this.selectedContractId));
}
private prepareSelectableItems(contracts: Contract[]) {
return _.map(contracts, (contract) => new SelectItem(contract.id, String(contract.id)));
}
private findSelectedContract(contracts: Contract[], contractId: number) {
return _.find(contracts, (contract) => contract.id === Number(contractId));
}
}

View File

@ -1,32 +1,29 @@
.tile
.text-center
h4 Выберите
.btn-group(data-toggle="buttons")
label.btn.btn-default((click)="selectOptionNew()")
input(type="radio", name="way", value="new")
span Новый
span Создать новый контракт
label.btn.btn-default((click)="selectOptionExisting()")
input(type="radio", name="way", value="existing")
span Существующий
span Выбрать существующий контракт
br
br
.tile
kof-create-contract(
*ngIf="selectedOption === optionNew",
[newContract]="args.contract",
(readyStateChange)="newContractReady($event)"
(onContractorReady)="onContractorReady($event)"
)
kof-select-contract(
*ngIf="selectedOption === optionExisting",
[contracts]="args.contracts",
(contractSelected)="contractSelected($event)"
(onContractSelected)="onContractSelected($event)"
)
.actionBar
.text-center
a.btn.btn-primary((click)="stepBackward()") Отмена
a.btn(
(click)="stepForward()",
[ngClass]="{'buttonDisabled': isContractReady === false, " +
[ngClass]="{'buttonDisabled': isContractorReady === false, " +
"'btn-default': showFinishButton === true," +
"'btn-success': showFinishButton === false}"
)

View File

@ -0,0 +1,58 @@
import { Component, Output, EventEmitter, Input } from '@angular/core';
import { SelectionOptions } from '../selection-options.class';
import { Contractor } from 'koffing/backend/classes/contractor.class';
import { ContractDecision } from 'koffing/management/components/management-container/shops/create-shop-wizard/selection-contract/contract-decision.class';
@Component({
selector: 'kof-selection-contract',
templateUrl: 'selection-contract.component.pug'
})
export class SelectionContractComponent {
@Input()
public showFinishButton: boolean = false;
public selectedOption: SelectionOptions;
public optionNew: number = SelectionOptions.New;
public optionExisting: number = SelectionOptions.Existing;
public isContractorReady: boolean = false;
public decision: ContractDecision = new ContractDecision();
@Output()
public steppedForward = new EventEmitter();
@Output()
public steppedBackward = new EventEmitter();
public onContractorReady(contractor: Contractor) {
this.isContractorReady = true;
this.decision.contractor = contractor;
}
public onContractSelected(contractID: number) {
this.isContractorReady = true;
this.decision.contractID = contractID;
}
public newContractReady(params: any) {
this.isContractorReady = params.valid;
}
public selectOptionNew() {
this.selectedOption = this.optionNew;
}
public selectOptionExisting() {
this.selectedOption = this.optionExisting;
this.isContractorReady = false;
}
public stepForward() {
if (this.isContractorReady) {
this.steppedForward.emit(this.decision);
}
}
public stepBackward() {
this.steppedBackward.emit();
}
}

View File

@ -1,6 +1,6 @@
.x_panel.tile
.x_title
h4 Добавление нового счета
h4 Добавление нового средства вывода
.x_content
form.form-horizontal.form-label-left.css-form(novalidate, name="form", #form="ngForm")
h5 Валюта
@ -10,7 +10,7 @@
label.text-left Валюта
.col-xs-12.col-sm-6
input.form-control(type="text", required, name="selected_currency",
[(ngModel)]="newPayoutAccount.currency", #selected_currency="ngModel",
[(ngModel)]="payoutTool.currency", #selected_currency="ngModel",
(keyup)="checkForm(form)")
.ln_solid
h5 Банковские реквизиты
@ -20,26 +20,26 @@
label.text-left Расчетный счет
.col-xs-12.col-sm-6
input.form-control(type="text", required, name="bank_account",
[(ngModel)]="newPayoutAccount.tool.bankAccount.account", #bank_account="ngModel",
[(ngModel)]="payoutTool.bankAccount.account", #bank_account="ngModel",
(keyup)="checkForm(form)")
.form-group([ngClass]="{'has-error': hasError(bank_name)}")
.col-xs-12.col-sm-3
label.text-left Наименование банка
.col-xs-12.col-sm-6
input.form-control(type="text", required, name="bank_name",
[(ngModel)]="newPayoutAccount.tool.bankAccount.bankName", #bank_name="ngModel",
[(ngModel)]="payoutTool.bankAccount.bankName", #bank_name="ngModel",
(keyup)="checkForm(form)")
.form-group([ngClass]="{'has-error': hasError(bank_post_account)}")
.col-xs-12.col-sm-3
label.text-left Корреспондентский счет
.col-xs-12.col-sm-6
input.form-control(type="text", required, name="bank_post_account",
[(ngModel)]="newPayoutAccount.tool.bankAccount.bankPostAccount", #bank_post_account="ngModel",
[(ngModel)]="payoutTool.bankAccount.bankPostAccount", #bank_post_account="ngModel",
(keyup)="checkForm(form)")
.form-group([ngClass]="{'has-error': hasError(bank_bik)}")
.col-xs-12.col-sm-3
label.text-left БИК
.col-xs-12.col-sm-6
input.form-control(type="text", required, name="bank_bik",
[(ngModel)]="newPayoutAccount.tool.bankAccount.bankBik", #bank_bik="ngModel",
[(ngModel)]="payoutTool.bankAccount.bankBik", #bank_bik="ngModel",
(keyup)="checkForm(form)")

View File

@ -0,0 +1,37 @@
import { Component, Output, EventEmitter, OnInit } from '@angular/core';
import { PayoutToolBankAccount } from 'koffing/backend/classes/payout-tool-bank-account.class';
import { BankAccount } from 'koffing/backend/classes/bank-account.class';
@Component({
selector: 'kof-create-paytool',
templateUrl: 'create-paytool.component.pug'
})
export class CreatePayoutToolComponent implements OnInit {
@Output()
public onPayoutToolReady = new EventEmitter();
public payoutTool: PayoutToolBankAccount;
public ngOnInit() {
this.payoutTool = this.getInstance();
}
public checkForm(form: any) {
if (form.valid) {
this.onPayoutToolReady.emit(this.payoutTool);
}
}
public hasError(field: any): boolean {
return field.dirty && field.invalid;
}
private getInstance() {
const bankAccount = new BankAccount();
const instance = new PayoutToolBankAccount();
instance.bankAccount = bankAccount;
return instance;
}
}

View File

@ -0,0 +1,9 @@
export class PaytoolDecision {
public contractID: number;
public payoutToolID: number;
constructor(contractID?: number, payoutToolID?: number) {
this.contractID = contractID;
this.payoutToolID = payoutToolID;
}
}

View File

@ -0,0 +1,44 @@
.x_panel.tile
.x_title
h4 Выбор существующего счета
kof-loading([isLoading]="isLoading")
.x_content
.tile
kof-select.col-xs-6(*ngIf="selectableItems.length", [(ngModel)]="selectedPayoutToolId", [items]="selectableItems", (onChange)="selectPayoutAccount()", [modelOptions]="{standalone: true}", name='selectedPayoutTool')
.ln_solid
form.form-horizontal.form-label-left.css-form(*ngIf="selectedPayoutToolId !== undefined", novalidate, (ngSubmit)="createShop(form)", name="form", #form="ngForm")
h5 Валюта
.ln_solid
.form-group
.col-xs-12.col-sm-3
label.text-left Валюта
.col-xs-12.col-sm-6
input.form-control(disabled, type="text", required, name="selected_currency",
[(ngModel)]="selectedPayoutTool.params.currency", #selected_currency="ngModel")
.ln_solid
h5 Банковские реквизиты
.ln_solid
.form-group
.col-xs-12.col-sm-3
label.text-left Расчетный счет
.col-xs-12.col-sm-6
input.form-control(disabled, type="text", required, name="bank_account",
[(ngModel)]="selectedPayoutTool.params.bankAccount.account", #bank_account="ngModel")
.form-group
.col-xs-12.col-sm-3
label.text-left Наименование банка
.col-xs-12.col-sm-6
input.form-control(disabled, type="text", required, name="bank_name",
[(ngModel)]="selectedPayoutTool.params.bankAccount.bankName", #bank_name="ngModel")
.form-group
.col-xs-12.col-sm-3
label.text-left Корреспондентский счет
.col-xs-12.col-sm-6
input.form-control(disabled, type="text", required, name="bank_post_account",
[(ngModel)]="selectedPayoutTool.params.bankAccount.bankPostAccount", #bank_post_account="ngModel")
.form-group
.col-xs-12.col-sm-3
label.text-left БИК
.col-xs-12.col-sm-6
input.form-control(disabled, type="text", required, name="bank_bik",
[(ngModel)]="selectedPayoutTool.params.bankAccount.bankBik", #bank_bik="ngModel")

View File

@ -0,0 +1,54 @@
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import * as _ from 'lodash';
import { SelectItem } from 'koffing/common/components/select/select.class';
import { PayoutTool } from 'koffing/backend/classes/payout-tool.class';
import { ContractService } from 'koffing/backend/services/contract.service';
@Component({
selector: 'kof-select-paytool',
templateUrl: 'select-paytool.component.pug'
})
export class SelectPaytoolComponent implements OnInit {
public selectableItems: SelectItem[] = [];
public selectedPayoutToolId: number;
public isLoading: boolean = true;
public selectedOption: string;
@Output()
public onPayoutToolSelected = new EventEmitter();
@Input()
public contractID: number;
private payoutTools: PayoutTool[];
private selectedPayoutTool: PayoutTool;
constructor(private contractService: ContractService) { }
public ngOnInit() {
this.contractService.getPayoutTools(this.contractID).then((payoutTools) => {
this.isLoading = false;
this.payoutTools = payoutTools;
this.selectableItems = this.prepareSelectableItems(payoutTools);
});
}
public selectPayoutAccount() {
this.selectedPayoutTool = this.findSelectedTool(this.payoutTools, this.selectedPayoutToolId);
this.onPayoutToolSelected.emit(_.toNumber(this.selectedPayoutToolId));
}
private prepareSelectableItems(payoutTools: PayoutTool[]) {
return _.map(payoutTools, (payoutTool) => new SelectItem(payoutTool.id, String(payoutTool.id)));
}
private findSelectedTool(payoutTools: PayoutTool[], payoutToolID: number) {
return _.find(payoutTools, (payoutTool) => payoutTool.id === Number(payoutToolID));
}
}

View File

@ -0,0 +1,34 @@
kof-loading([isLoading]="isLoading")
.tile(*ngIf="contractDecision.contractID !== undefined")
.text-center
h4 Выберите
.btn-group(data-toggle="buttons")
label.btn.btn-default((click)="selectOptionNew()")
input(type="radio", name="way", value="new")
span Добавить новое средство вывода
label.btn.btn-default((click)="selectOptionExisting()")
input(type="radio", name="way", value="existing")
span Выбрать существующее
br
br
.tile
kof-create-paytool(
*ngIf="selectedOption === optionNew",
(onPayoutToolReady)="onPayoutToolReady($event)"
)
kof-select-paytool(
*ngIf="selectedOption === optionExisting",
[contractID]="contractDecision.contractID",
(onPayoutToolSelected)="onPayoutToolSelected($event)"
)
.actionBar
.text-center
a.btn.btn-primary((click)="stepBackward()") Отмена
a.btn.btn-success(
(click)="stepForward()",
[ngClass]="{'buttonDisabled': isPayoutAccountReady === false, " +
"'btn-default': showFinishButton === true," +
"'btn-success': showFinishButton === false}"
)
span(*ngIf="showFinishButton === true") Завершить
span(*ngIf="showFinishButton === false") Вперед

View File

@ -0,0 +1,135 @@
import { Component, Output, EventEmitter, OnInit, Input } from '@angular/core';
import * as _ from 'lodash';
import { SelectionOptions } from '../selection-options.class';
import { Claim } from 'koffing/backend/classes/claim.class';
import { ClaimService } from 'koffing/backend/services/claim.service';
import { PayoutToolBankAccount } from 'koffing/backend/classes/payout-tool-bank-account.class';
import { ContractService } from 'koffing/backend/services/contract.service';
import { ContractParams } from 'koffing/backend/classes/contract-params.class';
import { ContractDecision } from 'koffing/management/components/management-container/shops/create-shop-wizard/selection-contract/contract-decision.class';
import { Contractor } from 'koffing/backend/classes/contractor.class';
import { PayoutToolParams } from 'koffing/backend/classes/payout-tool-params.class';
import { PaytoolDecision } from 'koffing/management/components/management-container/shops/create-shop-wizard/selection-paytool/paytool-decision.class';
@Component({
selector: 'kof-selection-paytool',
templateUrl: 'selection-paytool.component.pug'
})
export class SelectionPaytoolComponent implements OnInit {
@Input()
public showFinishButton: boolean = false;
@Input()
public contractDecision: ContractDecision;
public selectedOption: SelectionOptions;
public optionNew: number = SelectionOptions.New;
public optionExisting: number = SelectionOptions.Existing;
public isPayoutAccountReady: boolean = false;
public payoutToolsParams: PayoutToolBankAccount;
public payoutToolID: number;
public isLoading: boolean = false;
@Output()
public steppedForward = new EventEmitter();
@Output()
public steppedBackward = new EventEmitter();
constructor(private contractService: ContractService,
private claimService: ClaimService) {
}
public ngOnInit() {
if (!_.isUndefined(this.contractDecision.contractor)) {
this.selectedOption = this.optionNew;
}
}
public onPayoutToolReady(payoutTool: PayoutToolBankAccount) {
this.isPayoutAccountReady = true;
this.payoutToolsParams = payoutTool;
}
public onPayoutToolSelected(payoutToolID: number) {
this.isPayoutAccountReady = true;
this.payoutToolID = payoutToolID;
}
public selectOptionExisting() {
this.selectedOption = this.optionExisting;
this.isPayoutAccountReady = false;
}
public selectOptionNew() {
this.selectedOption = this.optionNew;
this.isPayoutAccountReady = false;
}
public stepForward() {
// new contract and new payout tools
if (!_.isUndefined(this.contractDecision.contractor) && !_.isUndefined(this.payoutToolsParams)) {
this.isLoading = true;
this.createContract(this.contractDecision.contractor, this.payoutToolsParams).then((decision: PaytoolDecision) => {
this.isLoading = false;
this.steppedForward.emit(decision);
});
// selected contract and new payout tools
} else if (!_.isUndefined(this.contractDecision.contractID) && !_.isUndefined(this.payoutToolsParams)) {
this.isLoading = true;
this.createPayoutTool(this.contractDecision.contractID, this.payoutToolsParams).then((decision: PaytoolDecision) => {
this.isLoading = false;
this.steppedForward.emit(decision);
});
// selected contract and selected payout tools
} else if (!_.isUndefined(this.contractDecision.contractID) && !_.isUndefined(this.payoutToolID)) {
this.steppedForward.emit(new PaytoolDecision(this.contractDecision.contractID, this.payoutToolID));
}
}
public stepBackward() {
this.steppedBackward.emit();
}
private createPayoutTool(contractID: number, payoutToolsParams: PayoutToolBankAccount) {
return new Promise((resolve) => {
this.contractService.createPayoutTool(contractID, payoutToolsParams).then((result: any) => {
this.claimService.getClaimById(result.claimID).then((claim: Claim) => {
const payoutToolID = this.getPayoutToolId(contractID, claim.changeset);
resolve(new PaytoolDecision(contractID, payoutToolID));
});
});
});
}
private createContract(contractor: Contractor, payoutToolsParams: PayoutToolParams): Promise<PaytoolDecision> {
const contractParams = new ContractParams();
contractParams.contractor = contractor;
contractParams.payoutToolParams = payoutToolsParams;
return new Promise((resolve) => {
this.contractService.createContract(contractParams).then((result: any) => {
this.claimService.getClaimById(result.claimID).then((claim: Claim) => {
const contractID = this.getContractId(claim.changeset);
const payoutToolID = this.getPayoutToolId(contractID, claim.changeset);
resolve(new PaytoolDecision(contractID, payoutToolID));
}
);
});
});
}
private getContractId(changeset: any[]): number {
const contractCreationChangeset = _.filter(changeset, (item) => item.partyModificationType === 'ContractCreation');
const sortedChangeset = _.sortBy(contractCreationChangeset, (item) => item.contract.id);
const last = _.last(sortedChangeset);
return last.contract.id;
}
private getPayoutToolId(contractId: number, changeset: any[]): number {
const payoutChangeset = _.filter(changeset, (item) =>
item.partyModificationType === 'ContractModification' && item.contractModificationType === 'ContractPayoutToolCreation');
const found = _.find(payoutChangeset, (item) => item.contractID === contractId);
return found.payoutTool.id;
}
}

View File

@ -3,43 +3,40 @@
.x_content
kof-loading([isLoading]="isLoading")
form.form-horizontal.form-label-left.css-form(novalidate, name="form", #form="ngForm")
.form-group
.col-xs-12.col-sm-3
label.text-left Категория *
.col-xs-12.col-sm-6
kof-select(
[(ngModel)]="categoryId",
[items]="categories",
[modelOptions]="{standalone: true}",
name="category")
.form-group([ngClass]="{'has-error': hasError(shop_details_name)}")
.col-xs-12.col-sm-3
label.text-left Название магазина *
.col-xs-12.col-sm-6
input.form-control(type="text", required, name="shop_details_name",
[(ngModel)]="shopFields.shopDetails.name", #shop_details_name="ngModel",
[(ngModel)]="shopDetail.name", #shop_details_name="ngModel",
(keyup)="checkForm(form)")
.form-group
.col-xs-12.col-sm-3
label.text-left Описание магазина
.col-xs-12.col-sm-6
input.form-control(type="text", name="shop_details_description",
[(ngModel)]="shopFields.shopDetails.description",
[(ngModel)]="shopDetail.description",
(keyup)="checkForm(form)")
.form-group
.col-xs-12.col-sm-3
label.text-left Месторасположение
label.text-left Сайт
.col-xs-12.col-sm-6
input.form-control(type="text", name="shop_details_location",
[(ngModel)]="shopFields.shopDetails.location",
[(ngModel)]="shopDetail.location.url",
(keyup)="checkForm(form)")
.form-group
.col-xs-12.col-sm-3
label.text-left URL для CallbackHandler
label.text-left CallbackHandler URL
.col-xs-12.col-sm-6
input.form-control(type="text", name="callback_handler_url",
[(ngModel)]="shopFields.callbackHandler.url",
[(ngModel)]="callbackUrl",
(keyup)="checkForm(form)")
.form-group
.col-xs-12.col-sm-3
label.text-left Категория *
.col-xs-12.col-sm-6
kof-select(
[(ngModel)]="shopFields.categoryRef",
[items]="categories",
(onChange)="selectCategory()",
[modelOptions]="{standalone: true}",
name="category"
)

View File

@ -0,0 +1,69 @@
import { Component, OnInit, Output, EventEmitter } from '@angular/core';
import * as _ from 'lodash';
import { CategoryService } from 'koffing/backend/backend.module';
import { SelectItem } from 'koffing/common/common.module';
import { ShopDetail } from 'koffing/backend/classes/shop-detail.class';
import { ShopLocationUrl } from 'koffing/backend/classes/shop-location-url.class';
@Component({
selector: 'kof-add-shop',
templateUrl: 'add-shop.component.pug'
})
export class AddShopComponent implements OnInit {
@Output()
public onShopReady = new EventEmitter();
public categories: SelectItem[] = [];
public isCategorySelected: boolean = false;
public isLoading: boolean = false;
public latestFormState: any;
public shopDetail: ShopDetail;
public categoryId: number;
public callbackUrl: string;
constructor(
private categoryService: CategoryService
) { }
public ngOnInit() {
this.isLoading = true;
this.getCategories().then(() => {
this.isLoading = false;
});
this.shopDetail = this.getInstance();
}
public getCategories() {
return new Promise((resolve) => {
this.categoryService.getCategories().then(categories => {
this.categories = _.map(categories, (category: any) => new SelectItem(category.categoryID, category.name));
resolve();
});
});
}
public hasError(field: any): boolean {
return field.dirty && field.invalid;
}
public checkForm(form: any) {
if (form.valid) {
this.onShopReady.emit({
shopDetail: this.shopDetail,
categoryId: _.toNumber(this.categoryId),
callbackUrl: this.callbackUrl
});
}
}
private getInstance(): ShopDetail {
const instance = new ShopDetail();
instance.location = new ShopLocationUrl();
return instance;
}
}

View File

@ -0,0 +1,7 @@
kof-loading([isLoading]="isLoading")
.tile
kof-add-shop((onShopReady)="shopFieldsReady($event)")
.actionBar
.text-center
a.btn.btn-primary((click)="stepBackward()") Отмена
a.btn.btn-success((click)="createShop()", [ngClass]="{'buttonDisabled': isShopFieldsReady === false }") Создать заявку

View File

@ -0,0 +1,53 @@
import { Component, Output, EventEmitter, Input } from '@angular/core';
import { CreateShopArgs } from 'koffing/backend/classes/create-shop-args.class';
import { PaytoolDecision } from 'koffing/management/components/management-container/shops/create-shop-wizard/selection-paytool/paytool-decision.class';
import { ShopService } from 'koffing/backend/services/shop.service';
@Component({
selector: 'kof-selection-shop-fields',
templateUrl: 'selection-shop-fields.component.pug'
})
export class SelectionShopComponent {
public isShopFieldsReady: boolean = false;
public isLoading = false;
@Input()
public payoutToolDecision: PaytoolDecision;
@Output()
public steppedBackward = new EventEmitter();
@Output()
public onCreated = new EventEmitter();
private createShopArgs: CreateShopArgs;
constructor(private shopService: ShopService) { }
public shopFieldsReady(params: any) {
this.isShopFieldsReady = true;
this.createShopArgs = new CreateShopArgs();
this.createShopArgs.contractID = this.payoutToolDecision.contractID;
this.createShopArgs.payoutToolID = this.payoutToolDecision.payoutToolID;
this.createShopArgs.categoryID = params.categoryId;
this.createShopArgs.callbackUrl = params.callbackUrl;
this.createShopArgs.details = params.shopDetail;
}
public createShop() {
this.isLoading = true;
if (this.isShopFieldsReady) {
this.shopService.createShop(this.createShopArgs).then(() => {
this.isLoading = false;
this.onCreated.emit();
});
}
}
public stepBackward() {
this.steppedBackward.emit();
}
}

View File

@ -1,11 +0,0 @@
.wizard_horizontal ul.wizard_steps li:first-child a:before {
width: 45%;
}
.wizard_horizontal ul.wizard_steps li:last-child a:before {
width: 58%;
}
.wizard_horizontal ul.wizard_steps {
left: -80px;
}

View File

@ -1,30 +0,0 @@
.row
.col-xs-12
.x_panel.tile
.x_title
h4 Изменение контракта магазина {{currentShopId}}
.x_content
.form_wizard.wizard_horizontal
ul.wizard_steps.anchor
li
a([ngClass]="{'done': currentStep > contractStep, 'selected': currentStep === contractStep}")
span.step_no 1
span.step_descr Выбор контракта
li
a([ngClass]="{'disabled': currentStep < accountStep, 'selected': currentStep === accountStep}")
span.step_no 2
span.step_descr Выбор счета
kof-loading([isLoading]="wizardArgs.isLoading")
kof-selection-contract(
*ngIf="currentStep === contractStep",
(steppedBackward)="returnToShopEditing()",
(steppedForward)="goToStep(accountStep)",
[args]="wizardArgs"
)
kof-selection-account(
*ngIf="currentStep === accountStep",
(steppedBackward)="returnToShopEditing()",
(steppedForward)="finish()",
[args]="wizardArgs",
[showFinishButton]="true"
)

View File

@ -1,93 +0,0 @@
import { Component, OnInit } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';
import * as _ from 'lodash';
import { ShopService } from 'koffing/backend/backend.module';
import { ContractService } from 'koffing/backend/services/contract.service';
import { ShopModificationArgs } from 'koffing/management/classes/shop-modification-args.class';
import { Shop } from 'koffing/backend/classes/shop.class';
@Component({
selector: 'kof-edit-shop-contract',
templateUrl: 'edit-shop-contract.component.pug',
styleUrls: ['edit-shop-contract.component.less']
})
export class EditShopContractComponent implements OnInit {
public currentStep: number;
public contractStep: number = 1;
public accountStep: number = 2;
public currentShopId: number = Number(this.route.snapshot.params['shopID']);
public wizardArgs: ShopModificationArgs = new ShopModificationArgs();
constructor(
private route: ActivatedRoute,
private router: Router,
private shopService: ShopService,
private contractService: ContractService
) {}
public returnToShopEditing() {
this.router.navigate([`/shops/edit/${this.currentShopId}`]);
}
public goToStep(step: number) {
this.currentStep = step;
}
public ngOnInit() {
this.wizardArgs.isLoading = true;
Promise.all([
this.loadContracts(),
this.loadShops()
]).then(() => {
this.wizardArgs.isLoading = false;
this.goToStep(this.contractStep);
});
}
public finish() {
this.updateShop().then(() => {
this.returnToShopEditing();
});
}
public loadShops() {
return new Promise((resolve) => {
this.shopService.getShops().then((shops: any) => {
const currentShop: Shop = _.find(shops, (shop: any) => shop.shopID === this.currentShopId);
this.wizardArgs.shopFields = currentShop;
resolve();
});
});
}
private loadContracts() {
return new Promise((resolve) => {
this.contractService.getContracts().then((contracts) => {
this.wizardArgs.contracts = contracts;
resolve();
});
});
}
private updateShop(): Promise<any> {
this.wizardArgs.isLoading = true;
return new Promise((resolve) => {
this.shopService.updateShop(this.currentShopId, _.merge(
this.wizardArgs.shopFields,
{ contractID: this.wizardArgs.contract.id },
{ payoutAccountID: this.wizardArgs.payoutAccount.id }
)).then(() => {
this.wizardArgs.isLoading = false;
resolve();
});
});
}
}

View File

@ -1,14 +0,0 @@
.row
.col-xs-12
.x_panel.tile
.x_title
h4 Изменение счета по контракту {{currentContractId}} магазина {{currentShopId}}
.x_content
kof-loading([isLoading]="args.isLoading")
kof-selection-account(
*ngIf="currentStep === accountStep",
(steppedBackward)="returnToShopEditing()",
(steppedForward)="finish()",
[args]="args",
[showFinishButton]="true"
)

View File

@ -1,85 +0,0 @@
import { Component, OnInit } from '@angular/core';
import { Router, ActivatedRoute } from '@angular/router';
import * as _ from 'lodash';
import { ShopService } from 'koffing/backend/backend.module';
import { ContractService } from 'koffing/backend/services/contract.service';
import { ShopModificationArgs } from 'koffing/management/classes/shop-modification-args.class';
import { Shop } from 'koffing/backend/classes/shop.class';
@Component({
selector: 'kof-edit-shop-payout-account',
templateUrl: 'edit-shop-payout-account.component.pug'
})
export class EditShopPayoutAccountComponent implements OnInit {
public currentShopId: number = Number(this.route.snapshot.params['shopID']);
public currentContractId: number = Number(this.route.snapshot.params['contractID']);
public args: ShopModificationArgs = new ShopModificationArgs();
constructor(
private route: ActivatedRoute,
private router: Router,
private shopService: ShopService,
private contractService: ContractService
) {}
public returnToShopEditing() {
this.router.navigate([`/shops/edit/${this.currentShopId}`]);
}
public ngOnInit() {
this.args.isLoading = true;
Promise.all([
this.loadShops(),
this.loadContract()
]).then(() => {
this.args.isLoading = false;
});
}
public finish() {
this.updateShop().then(() => {
this.returnToShopEditing();
});
}
public loadShops() {
return new Promise((resolve) => {
this.shopService.getShops().then((shops: any) => {
const currentShop: Shop = _.find(shops, (shop: any) => shop.shopID === this.currentShopId);
this.args.shopFields = currentShop;
resolve();
});
});
}
public loadContract() {
return new Promise((resolve) => {
this.contractService.getContract(this.currentContractId).then(
(contract) => {
this.args.contract = contract;
resolve();
});
});
}
private updateShop(): Promise<any> {
this.args.isLoading = true;
return new Promise((resolve) => {
this.shopService.updateShop(this.currentShopId, _.merge(
this.args.shopFields,
{ contractID: this.currentContractId },
{ payoutAccountID: this.args.payoutAccount.id }
)).then(() => {
this.args.isLoading = false;
resolve();
});
});
}
}

View File

@ -5,65 +5,62 @@
h4 Изменение данных магазина
.x_content
kof-loading([isLoading]="isLoading")
form.form-horizontal.form-label-left.css-form(novalidate, (ngSubmit)="updateShop(form)", name="form", #form="ngForm")
.form-group([ngClass]="{'has-error': hasError(shop_details_name)}")
form.form-horizontal.form-label-left.css-form(*ngIf="shop", novalidate, (ngSubmit)="updateShop(form)", name="form", #form="ngForm")
.form-group([ngClass]="{'has-error': hasError(shopName)}")
.col-xs-12.col-sm-3
label.text-left Название магазина *
.col-xs-12.col-sm-6
input.form-control(type="text", required, name="shop_details_name",
[(ngModel)]="args.shopDetails.name", #shop_details_name="ngModel")
input.form-control(type="text", [ngModel]="shop.details.name", (ngModelChange)="onFieldChange('details.name', $event)", name="shopName", #shopName="ngModel", required)
.form-group
.col-xs-12.col-sm-3
label.text-left Описание магазина
.col-xs-12.col-sm-6
input.form-control(type="text", name="shop_details_description", [(ngModel)]="args.shopDetails.description")
input.form-control(type="text", [ngModel]="shop.details.description", (ngModelChange)="onFieldChange('details.description', $event)", name="shopDescription")
.form-group
.col-xs-12.col-sm-3
label.text-left Месторасположение
label.text-left Адрес
.col-xs-12.col-sm-6
input.form-control(type="text", name="shop_details_location", [(ngModel)]="args.shopDetails.location")
input.form-control(type="text", [ngModel]="shop.details.location.url", (ngModelChange)="onFieldChange('details.location.url', $event)", name="shopLocation")
.form-group
.col-xs-12.col-sm-3
label.text-left Контракт
.col-xs-12.col-sm-3
input.form-control(disabled, type="text", name="contractId", [(ngModel)]="args.contractId")
.col-xs-12.col-sm-3
a.btn.btn-dark((click)="showContractDetails = !showContractDetails")
span(*ngIf="showContractDetails === false") Просмотр
span(*ngIf="showContractDetails === true") Скрыть
a.btn.btn-dark([routerLink]="['/shops/edit/', currentShopId, 'contract']") Изменение
.form-group(*ngIf="showContractDetails === true")
.col-xs-12.col-sm-3
label.text-left Детали контракта
.col-xs-12.col-sm-6
kof-contract-view([contract]="shopContract", [showAccounts]="false")
.form-group
.col-xs-12.col-sm-3
label.text-left Счет
.col-xs-12.col-sm-3
input.form-control(disabled, type="text", name="payoutAccountId", [(ngModel)]="args.payoutAccountId")
.col-xs-12.col-sm-3
a.btn.btn-dark((click)="showPayoutAccountDetails = !showPayoutAccountDetails")
span(*ngIf="showPayoutAccountDetails === false") Просмотр
span(*ngIf="showPayoutAccountDetails === true") Скрыть
a.btn.btn-dark([routerLink]="['/shops/edit/', currentShopId, 'contract', args.contractId, 'account']") Изменение
.form-group(*ngIf="showPayoutAccountDetails === true")
kof-select([ngModel]="shop.contractID", [items]="contractItems", (onChange)="selectContract($event)", name='contractID')
// .col-xs-12.col-sm-3
// a.btn.btn-dark((click)="isShowContractDetails = !isShowContractDetails")
// span(*ngIf="!isShowContractDetails") Просмотр
// span(*ngIf="isShowContractDetails") Скрыть
//.form-group(*ngIf="isShowContractDetails")
// .col-xs-12.col-sm-3
// label.text-left Детали контракта
// .col-xs-12.col-sm-6
// kof-contract-view([contract]="shopContract", [isShowPayoutTools]="false")
//.form-group
// .col-xs-12.col-sm-3
// label.text-left Счет
// .col-xs-12.col-sm-3
// kof-select([(ngModel)]="shop.payoutToolID", [items]="payoutToolItems", (onChange)="selectPayoutTool($event)", name='payoutToolID')
// .col-xs-12.col-sm-3
// a.btn.btn-dark((click)="isShowPayoutAccountDetails = !isShowPayoutAccountDetails")
// span(*ngIf="!isShowPayoutAccountDetails") Просмотр
// span(*ngIf="isShowPayoutAccountDetails") Скрыть
.form-group(*ngIf="isShowPayoutAccountDetails")
.col-xs-12.col-sm-3
label.text-left Детали счета
.col-xs-12.col-sm-6
kof-payout-account-view([payoutAccount]="shopPayoutAccount")
kof-payout-tool-view([payoutTool]="shopPayoutTool")
.form-group
.col-xs-12.col-sm-3
label.text-left Категория *
label.text-left Категория
.col-xs-12.col-sm-6
kof-select([(ngModel)]="args.categoryRef", [items]="categories", [modelOptions]="{standalone: true}", name='category')
kof-select([ngModel]="shop.categoryID", (onChange)="onSelectCategory($event)", [items]="categoryItems", name='category')
.form-group
.col-xs-12.col-sm-3
label.text-left URL для CallbackHandler
label.text-left CallbackHandler URL
.col-xs-12.col-sm-6
input.form-control(type="text", name="callback_handler_url", [(ngModel)]="args.callbackHandlerUrl")
input.form-control(type="text", [ngModel]="shop.callbackHandler.url", (ngModelChange)="onFieldChange('callbackHandler.url', $event)", name="callbackHandlerUrl")
.ln_solid
.form-group
.col-xs-12.col-sm-6.col-sm-offset-3
button.btn.btn-primary(type="submit", [disabled]="form.invalid || form.pristine") Создать заявку
a.btn.btn-default.pull-right(type="reset", routerLink="/management") Назад
a.btn.btn-default.pull-right(type="reset", [routerLink]=["/management"]) Назад

View File

@ -4,88 +4,129 @@ import * as _ from 'lodash';
import { CategoryService } from 'koffing/backend/backend.module';
import { ShopService } from 'koffing/backend/backend.module';
import { SelectItem } from 'koffing/common/common.module';
import { Shop } from 'koffing/backend/classes/shop.class';
import { Contract } from 'koffing/backend/classes/contract.class';
import { PayoutAccount } from 'koffing/backend/classes/payout-account.class';
import { PayoutTool } from 'koffing/backend/classes/payout-tool.class';
import { ContractService } from 'koffing/backend/services/contract.service';
import { Category } from 'koffing/backend/classes/category.class';
import { SelectItem } from 'koffing/common/common.module';
import { CreateShopArgs } from 'koffing/backend/classes/create-shop-args.class';
import { ShopDetail } from 'koffing/backend/classes/shop-detail.class';
import { ShopLocationUrl } from 'koffing/backend/classes/shop-location-url.class';
@Component({
selector: 'kof-edit-shop',
templateUrl: './edit-shop.component.pug',
templateUrl: 'edit-shop.component.pug',
})
export class EditShopComponent implements OnInit {
public categories: SelectItem[] = [];
public currentShopId: number = Number(this.route.snapshot.params['shopID']);
public args: any = {
shopDetails: {},
categoryRef: 0,
contractId: 0,
payoutAccountId: 0,
callbackHandlerUrl: ''
};
public shopContract: Contract;
public shopPayoutAccount: PayoutAccount;
public showContractDetails: boolean = false;
public showPayoutAccountDetails: boolean = false;
public shopID: number = Number(this.route.snapshot.params['shopID']);
public shopEditing: CreateShopArgs;
public shop: Shop;
public shopContract: Contract = new Contract();
public shopPayoutTool: PayoutTool = new PayoutTool();
public contracts: Contract[] = [];
public payoutTools: PayoutTool[] = [];
private isLoading: boolean;
public contractItems: SelectItem[] = [];
public payoutToolItems: SelectItem[] = [];
public categoryItems: SelectItem[] = [];
constructor(
private route: ActivatedRoute,
private router: Router,
private categoryService: CategoryService,
private shopService: ShopService,
private contractService: ContractService
) {}
public isShowContractDetails: boolean = false;
public isShowPayoutAccountDetails: boolean = false;
public isLoading: boolean = false;
public returnToManagement() {
this.router.navigate(['/management']);
constructor(private route: ActivatedRoute,
private router: Router,
private categoryService: CategoryService,
private shopService: ShopService,
private contractService: ContractService) {
}
public loadDetails(contractId: number, payoutAccountId: number): Promise<any> {
return new Promise((resolve) => {
this.contractService.getContract(contractId).then(
(contract) => {
this.shopContract = contract;
this.shopPayoutAccount = _.find(contract.payoutAccounts,
(payoutAccount: PayoutAccount) => payoutAccount.id === payoutAccountId
);
resolve();
}
);
public ngOnInit() {
this.shopEditing = this.getInstance();
this.isLoading = true;
Promise.all([
this.loadCategories(),
this.loadShop()
]).then(() => {
this.isLoading = false;
});
}
public loadShops() {
return new Promise((resolve) => {
this.shopService.getShops().then((shops: any) => {
const currentShop: Shop = _.find(shops, (shop: any) => shop.shopID === this.currentShopId);
this.args.shopDetails = currentShop.shopDetails ? currentShop.shopDetails : {};
this.args.categoryRef = currentShop.categoryRef;
this.args.contractId = currentShop.contractID;
this.args.payoutAccountId = currentShop.payoutAccountID;
this.args.callbackHandlerUrl = currentShop.callbackHandler.url;
this.loadDetails(currentShop.contractID, currentShop.payoutAccountID).then(() => {
resolve();
public onFieldChange(path: string, value: any) {
_.set(this.shopEditing, path, value);
if (path === 'details.location.url') { // TODO fix it
const location = new ShopLocationUrl();
location.url = value;
this.shopEditing.details.location = location;
}
}
public loadCategories(): Promise<Category[]> {
return new Promise((resolve) => {
this.categoryService.getCategories().then((categories: Category[]) => {
this.categoryItems = _.map(categories, (category) => new SelectItem(category.categoryID, category.name));
resolve(categories);
});
});
}
public loadShop(): Promise<Shop> {
return new Promise((resolve) => {
this.shopService.getShop(this.shopID).then((shop: Shop) => {
Promise.all([
this.loadShopContracts(),
this.loadShopPayoutTools()
]).then(() => {
this.shop = shop;
resolve(shop);
});
});
});
}
public loadCategories() {
public loadShopContracts(): Promise<Contract[]> {
return new Promise((resolve) => {
this.categoryService.getCategories().then(aCategories => {
this.categories = _.map(aCategories, (cat: any) => new SelectItem(cat.categoryRef, cat.name));
resolve();
this.contractService.getContracts().then((contracts: Contract[]) => {
this.contracts = contracts;
this.shopContract = _.find(contracts, (contract) => contract.id === this.shopEditing.contractID);
this.contractItems = _.map(contracts, (contract) => new SelectItem(contract.id, contract.id));
resolve(contracts);
});
});
}
public loadShopPayoutTools(): Promise<PayoutTool[]> {
return new Promise((resolve) => {
if (this.shopEditing.contractID) {
this.contractService.getPayoutTools(this.shopEditing.contractID).then((payoutTools: PayoutTool[]) => {
this.payoutTools = payoutTools;
this.shopPayoutTool = _.find(payoutTools, (payoutTool) => payoutTool.id === this.shopEditing.payoutToolID);
if (!this.shopPayoutTool) {
this.shopPayoutTool = payoutTools[0];
this.shopEditing.payoutToolID = this.shopPayoutTool.id;
}
this.payoutToolItems = _.map(payoutTools, (payoutTool) => new SelectItem(payoutTool.id, payoutTool.id));
resolve(payoutTools);
});
} else {
resolve();
}
});
}
public selectContract(contractID: string) {
this.shopEditing.contractID = Number(contractID);
// this.shopContract = _.find(this.contracts, (contract) => contract.id === this.shopEditing.contractID);
// this.loadShopPayoutTools();
}
public selectPayoutTool(payoutToolID: string) {
this.shopEditing.payoutToolID = Number(payoutToolID);
this.shopPayoutTool = _.find(this.payoutTools, (payoutTool) => payoutTool.id === this.shopEditing.payoutToolID);
}
public hasError(field: any): boolean {
return field.dirty && field.invalid;
}
@ -93,22 +134,26 @@ export class EditShopComponent implements OnInit {
public updateShop(form: any) {
if (form.valid) {
this.isLoading = true;
this.shopService.updateShop(this.currentShopId, this.args).then(() => {
const detailsName = this.shopEditing.details.name;
this.shopEditing.details.name = detailsName ? detailsName : this.shop.details.name; // TODO fix it
if (this.shopEditing.categoryID) { // TODO fix it
this.shopEditing.categoryID = _.toNumber(this.shopEditing.categoryID);
}
this.shopService.updateShop(this.shopID, this.shopEditing).then(() => {
this.isLoading = false;
this.returnToManagement();
this.router.navigate(['/management']);
});
}
}
public ngOnInit() {
this.isLoading = true;
Promise.all([
this.loadShops(),
this.loadCategories()
]).then(() => {
this.isLoading = false;
});
public onSelectCategory(categoryID: string) {
this.shopEditing.categoryID = _.toNumber(categoryID);
}
private getInstance(): CreateShopArgs {
const shopDetail = new ShopDetail();
const instance = new CreateShopArgs();
instance.details = shopDetail;
return instance;
}
}

View File

@ -1,39 +0,0 @@
import { Component, Input, Output, EventEmitter } from '@angular/core';
import { PayoutAccount } from 'koffing/backend/backend.module';
@Component({
selector: 'kof-create-payout-account',
templateUrl: 'create-payout-account.component.pug'
})
export class CreatePayoutAccountComponent {
@Input()
public newPayoutAccount: PayoutAccount;
@Output()
public readyStateChange = new EventEmitter();
private isOnceValid: boolean = false;
public checkForm(form: any) {
let emit = () => {
this.readyStateChange.emit({
payoutAccount: this.newPayoutAccount,
valid: form.valid
});
};
if (form.valid) {
emit();
this.isOnceValid = true;
} else if (!form.valid && this.isOnceValid) {
emit();
this.isOnceValid = false;
}
}
public hasError(field: any): boolean {
return field.dirty && field.invalid;
}
}

View File

@ -1,43 +0,0 @@
.x_panel.tile
.x_title
h4 Выбор существующего счета
.x_content
.tile
kof-select.col-xs-6(*ngIf="selectableItems.length", [(ngModel)]="selectedPayoutAccountId", [items]="selectableItems", (onChange)="selectPayoutAccount()", [modelOptions]="{standalone: true}", name='selectedPayoutAccount')
.ln_solid
form.form-horizontal.form-label-left.css-form(*ngIf="selectedPayoutAccountId !== undefined", novalidate, (ngSubmit)="createShop(form)", name="form", #form="ngForm")
h5 Валюта
.ln_solid
.form-group
.col-xs-12.col-sm-3
label.text-left Валюта
.col-xs-12.col-sm-6
input.form-control(disabled, type="text", required, name="selected_currency",
[(ngModel)]="selectedPayoutAccount.currency", #selected_currency="ngModel")
.ln_solid
h5 Банковские реквизиты
.ln_solid
.form-group
.col-xs-12.col-sm-3
label.text-left Расчетный счет
.col-xs-12.col-sm-6
input.form-control(disabled, type="text", required, name="bank_account",
[(ngModel)]="selectedPayoutAccount.tool.bankAccount.account", #bank_account="ngModel")
.form-group
.col-xs-12.col-sm-3
label.text-left Наименование банка
.col-xs-12.col-sm-6
input.form-control(disabled, type="text", required, name="bank_name",
[(ngModel)]="selectedPayoutAccount.tool.bankAccount.bankName", #bank_name="ngModel")
.form-group
.col-xs-12.col-sm-3
label.text-left Корреспондентский счет
.col-xs-12.col-sm-6
input.form-control(disabled, type="text", required, name="bank_post_account",
[(ngModel)]="selectedPayoutAccount.tool.bankAccount.bankPostAccount", #bank_post_account="ngModel")
.form-group
.col-xs-12.col-sm-3
label.text-left БИК
.col-xs-12.col-sm-6
input.form-control(disabled, type="text", required, name="bank_bik",
[(ngModel)]="selectedPayoutAccount.tool.bankAccount.bankBik", #bank_bik="ngModel")

View File

@ -1,43 +0,0 @@
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core';
import * as _ from 'lodash';
import { SelectItem } from 'koffing/common/components/select/select.class';
import { PayoutAccount } from 'koffing/backend/classes/payout-account.class';
@Component({
selector: 'kof-select-payout-account',
templateUrl: 'select-payout-account.component.pug'
})
export class SelectPayoutAccountComponent implements OnInit {
public selectableItems: SelectItem[] = [];
public selectedPayoutAccountId: number;
@Output()
public payoutAccountSelected = new EventEmitter();
@Input()
private payoutAccounts: PayoutAccount[];
private selectedPayoutAccount: PayoutAccount;
public selectPayoutAccount() {
this.selectedPayoutAccount = _.find(this.payoutAccounts, (payoutAccount) => {
return payoutAccount.id === Number(this.selectedPayoutAccountId);
});
this.payoutAccountSelected.emit({
payoutAccount: this.selectedPayoutAccount
});
}
public prepareSelectableItems() {
this.selectableItems = _.map(this.payoutAccounts, (payoutAccount) => {
return new SelectItem(payoutAccount.id, String(payoutAccount.id));
});
}
public ngOnInit() {
this.prepareSelectableItems();
}
}

View File

@ -1,34 +0,0 @@
.tile(*ngIf="!args.isNewContract")
.text-center
h4 Выберите
.btn-group(data-toggle="buttons")
label.btn.btn-default((click)="selectOptionNew()")
input(type="radio", name="way", value="new")
span Новый
label.btn.btn-default((click)="selectOptionExisting()")
input(type="radio", name="way", value="existing")
span Существующий
br
br
.tile
kof-create-payout-account(
*ngIf="selectedOption === optionNew",
[newPayoutAccount]="args.payoutAccount",
(readyStateChange)="newPayoutAccountReady($event)"
)
kof-select-payout-account(
*ngIf="selectedOption === optionExisting",
[payoutAccounts]="args.contract.payoutAccounts",
(payoutAccountSelected)="payoutAccountSelected($event)"
)
.actionBar
.text-center
a.btn.btn-primary((click)="stepBackward()") Отмена
a.btn.btn-success(
(click)="stepForward()",
[ngClass]="{'buttonDisabled': isPayoutAccountReady === false, " +
"'btn-default': showFinishButton === true," +
"'btn-success': showFinishButton === false}"
)
span(*ngIf="showFinishButton === true") Завершить
span(*ngIf="showFinishButton === false") Вперед

View File

@ -1,118 +0,0 @@
import { Component, Output, EventEmitter, OnInit, Input } from '@angular/core';
import * as _ from 'lodash';
import { SelectionOptions } from '../selection-options.class';
import { ShopModificationArgs } from 'koffing/management/management.module';
import { Claim } from 'koffing/backend/classes/claim.class';
import { ClaimService } from 'koffing/backend/services/claim.service';
import { BankAccount } from 'koffing/backend/classes/bank-account.class';
import { PayoutToolBankAccount } from 'koffing/backend/classes/payout-tool-bank-account.class';
import { PayoutAccount } from 'koffing/backend/classes/payout-account.class';
import { ContractService } from 'koffing/backend/services/contract.service';
@Component({
selector: 'kof-selection-account',
templateUrl: 'selection-account.component.pug'
})
export class SelectionAccountComponent implements OnInit {
@Input()
public showFinishButton: boolean = false;
public selectedOption: SelectionOptions;
public optionNew: number = SelectionOptions.New;
public optionExisting: number = SelectionOptions.Existing;
public isPayoutAccountReady: boolean = false;
@Output()
public steppedForward = new EventEmitter();
@Output()
public steppedBackward = new EventEmitter();
@Input()
private args: ShopModificationArgs;
constructor(
private contractService: ContractService,
private claimService: ClaimService
) { }
public ngOnInit() {
this.removePayoutAccountInstance();
if (this.args.isNewContract) {
this.selectOptionNew();
}
}
public removePayoutAccountInstance() {
delete this.args.payoutAccount;
this.isPayoutAccountReady = false;
}
public createNewPayoutAccountInstance() {
const bankAccountArgs = new BankAccount();
const payoutToolBankAccount = new PayoutToolBankAccount();
payoutToolBankAccount.bankAccount = bankAccountArgs;
this.args.payoutAccount = new PayoutAccount();
this.args.payoutAccount.tool = payoutToolBankAccount;
this.isPayoutAccountReady = false;
}
public selectOptionNew() {
this.createNewPayoutAccountInstance();
this.selectedOption = this.optionNew;
}
public selectOptionExisting() {
this.removePayoutAccountInstance();
this.selectedOption = this.optionExisting;
}
public newPayoutAccountReady(params: any) {
this.isPayoutAccountReady = params.valid;
}
public payoutAccountSelected(params: any) {
this.args.payoutAccount = params.payoutAccount;
this.isPayoutAccountReady = true;
}
public createPayoutAccount() {
this.args.isLoading = true;
this.contractService.createPayoutAccount(this.args.contract.id, this.args.payoutAccount).then(
(result: any) => {
this.claimService.getClaimById(result.claimID).then(
(claim: Claim) => {
this.args.isLoading = false;
let payoutAccountCreationChangeset = _.find(claim.changeset, (set) => {
return set.modificationType === 'PayoutAccountCreation';
});
this.args.payoutAccount = payoutAccountCreationChangeset.payoutAccount;
this.confirmForward();
}
);
}
);
}
public stepForward() {
if (this.selectedOption === this.optionNew) {
this.createPayoutAccount();
} else {
this.confirmForward();
}
}
public stepBackward() {
this.confirmBackward();
}
private confirmForward() {
this.steppedForward.emit();
}
private confirmBackward() {
this.steppedBackward.emit();
}
}

Some files were not shown because too many files have changed in this diff Show More