docs: configurando deploy via ssh para angular

This commit is contained in:
2026-01-02 19:55:27 -05:00
parent a16d0f0701
commit b0beb50d59
544 changed files with 97696 additions and 0 deletions

View File

@@ -0,0 +1,422 @@
<div class="container form-partner m-2">
<form class="k-form shadow bg-body rounded" [formGroup]="formPartner">
<legend>
<h5>CADASTRO DE PROFISSIONAL</h5>
</legend>
<kendo-formfield>
<label>
<span>CPF</span>
<kendo-textbox
formControlName="cpf"
[clearButton]="true"
#cpf
required
></kendo-textbox>
</label>
<kendo-formerror>Error: CPF é obrigatório</kendo-formerror>
</kendo-formfield>
<kendo-formfield>
<label>
<span>Nome</span>
<kendo-textbox
formControlName="name"
[clearButton]="true"
#fullName
required
></kendo-textbox>
</label>
<kendo-formerror>Error: Nome é obrigatório</kendo-formerror>
</kendo-formfield>
<kendo-formfield showHints="initial">
<label class="k-label">Tipo de parceiro</label>
<ul class="k-radio-list">
<li class="k-radio-item">
<label>
<input
type="radio"
#parceiro
kendoRadioButton
value="B"
formControlName="type"
(change)="parceiroBellaObra()"
/>
<span> Bella Obra</span>
</label>
</li>
<li class="k-radio-item">
<label>
<input
type="radio"
#mestre
value="M"
kendoRadioButton
formControlName="type"
(change)="parceiroBellaObra()"
/>
<span> Parceiro</span>
</label>
</li>
<li class="k-radio-item">
<label>
<input
type="radio"
#parceiro
kendoRadioButton
value="P"
formControlName="type"
(change)="parceiroBellaObra()"
/>
<span> Mestre</span>
</label>
</li>
</ul>
<kendo-formerror *ngIf="formPartner.controls.type.errors?.required"
>Error: O tipo do parceiro é obrigatório</kendo-formerror
>
</kendo-formfield>
<kendo-formfield showHints="initial">
<label>
<span class="ms-2">Comissão (%)</span>
<kendo-numerictextbox
formControlName="commission"
[decimals]="2"
format="#.00"
>
</kendo-numerictextbox>
</label>
</kendo-formfield>
<kendo-formfield showHints="initial">
<label>
<input
kendoCheckBox
id="terms"
type="checkbox"
formControlName="buyer"
/>
<span class="ms-2">Parceiro é comprador de cliente PJ?</span>
</label>
</kendo-formfield>
<kendo-formfield showHints="initial">
<label>
<input
kendoCheckBox
id="terms"
type="checkbox"
formControlName="buyer"
/>
<span class="ms-2">Parceiro é comprador de cliente PJ?</span>
</label>
</kendo-formfield>
<kendo-formfield>
<label>
<span>Cliente</span>
<kendo-combobox
textField="name"
valueField="customerId"
formControlName="customer"
[data]="customer$ | async"
[loading]="loadingCustomer"
[filterable]="true"
(filterChange)="handleFilterCustomer($event)"
placeholder="Selecione o cliente..."
(selectionChange)="selectCustomer($event)"
>
</kendo-combobox>
</label>
</kendo-formfield>
<kendo-formfield>
<label>
<span>Email</span>
<kendo-textbox
formControlName="email"
[clearButton]="true"
#email
required
></kendo-textbox>
</label>
<kendo-formerror *ngIf="formPartner.controls.type.errors?.required"
>Error: Email is required</kendo-formerror
>
<kendo-formerror *ngIf="formPartner.controls.email.errors?.email"
>Error: Not valid email format</kendo-formerror
>
</kendo-formfield>
<kendo-formfield>
<label>
<span>RG</span>
<kendo-textbox
formControlName="rg"
[clearButton]="true"
#rg
required
></kendo-textbox>
</label>
<kendo-formerror *ngIf="formPartner.controls.rg.errors?.rg"
>Error: RG é obrigaário</kendo-formerror
>
</kendo-formfield>
<kendo-formfield>
<label>
<span>Registro Profissional</span>
<kendo-textbox
formControlName="professionalNumber"
[clearButton]="true"
#professionalnumber
required
></kendo-textbox>
</label>
</kendo-formfield>
<kendo-formfield>
<label>
<span>Telefone (Whatsapp)</span>
<kendo-textbox
formControlName="phone"
[clearButton]="true"
#phone
required
></kendo-textbox>
</label>
</kendo-formfield>
<kendo-formfield>
<label>
<span>Chave PIX</span>
<kendo-textbox
formControlName="pixKey"
[clearButton]="true"
#pixKey
required
></kendo-textbox>
</label>
</kendo-formfield>
<kendo-formfield>
<label>
<span>Vendedor</span>
<kendo-combobox
textField="name"
valueField="sellerId"
formControlName="seller"
[data]="sellers"
[kendoDropDownFilter]="{ operator: 'contains' }"
placeholder="Selecione o vendedor que indicou o parceiro..."
(selectionChange)="selectSeller($event)"
>
</kendo-combobox>
</label>
</kendo-formfield>
<kendo-formfield>
<label>
<span>Categoria</span>
<kendo-combobox
textField="name"
valueField="id"
formControlName="category"
[data]="categoryPartners"
[kendoDropDownFilter]="{ operator: 'contains' }"
placeholder="Selecione a categoria do parceiro..."
(selectionChange)="selectCategory($event)"
>
</kendo-combobox>
</label>
</kendo-formfield>
<h4 class="my-3">ENDEREÇO</h4>
<kendo-formfield>
<label>
<span>Cep</span>
<kendo-textbox
formControlName="zipCode"
[clearButton]="true"
#zipCode
required
(blur)="consultaCep()"
></kendo-textbox>
</label>
</kendo-formfield>
<kendo-formfield>
<label>
<span>Endereço</span>
<kendo-textbox
formControlName="address"
[clearButton]="true"
#address
required
></kendo-textbox>
</label>
</kendo-formfield>
<kendo-formfield>
<label>
<span>Número</span>
<kendo-textbox
formControlName="number"
[clearButton]="true"
#number
required
></kendo-textbox>
</label>
</kendo-formfield>
<kendo-formfield>
<label>
<span>Complemento</span>
<kendo-textbox
formControlName="complement"
[clearButton]="true"
#complement
required
></kendo-textbox>
</label>
</kendo-formfield>
<kendo-formfield>
<label>
<span>Bairro</span>
<kendo-textbox
formControlName="neighborhood"
[clearButton]="true"
#neighborhood
required
></kendo-textbox>
</label>
</kendo-formfield>
<kendo-formfield>
<label>
<span>Cidade</span>
<kendo-textbox
formControlName="city"
[clearButton]="true"
#neighborhood
required
></kendo-textbox>
</label>
</kendo-formfield>
<kendo-formfield>
<label>
<span>Estado</span>
<kendo-textbox
formControlName="state"
[clearButton]="true"
#state
required
></kendo-textbox>
</label>
</kendo-formfield>
<h4 class="my-3">DADOS BANCÁRIOS</h4>
<div class="row">
<div class="col-12 col-sm-12 col-md-12 col-xl-4">
<kendo-formfield>
<label>
<span>Banco</span>
<kendo-textbox
formControlName="bank"
[clearButton]="true"
#bank
required
></kendo-textbox>
</label>
</kendo-formfield>
</div>
<div class="col-12 col-sm-12 col-md-12 col-xl-4">
<kendo-formfield>
<label>
<span>Agencia</span>
<kendo-textbox
formControlName="agencia"
[clearButton]="true"
#agencia
required
></kendo-textbox>
</label>
</kendo-formfield>
</div>
<div class="col-12 col-sm-12 col-md-4 col-xl-4">
<kendo-formfield>
<label>
<span>Conta</span>
<kendo-textbox
formControlName="conta"
[clearButton]="true"
#conta
required
></kendo-textbox>
</label>
</kendo-formfield>
</div>
</div>
<h4 class="my-3">OBSERVAÇÕES</h4>
<label>
<span>Observações</span>
<kendo-textbox
formControlName="observer1"
[clearButton]="true"
#observer1
required
></kendo-textbox>
</label>
<label>
<kendo-textbox
formControlName="observer2"
[clearButton]="true"
#observer2
required
></kendo-textbox>
</label>
<div class="k-form-buttons">
<button kendoButton themeColor="primary" (click)="submitForm()">
Salvar
</button>
<button kendoButton (click)="clearForm()">Cancelar</button>
</div>
</form>
</div>
<!--
name: new FormControl('', [Validators.required, Validators.minLength(10), ], ),
cpf: new FormControl('', [Validators.required], ),
type: new FormControl('', [Validators.required], ),
rg: new FormControl('', [Validators.required], ),
professionalNumber: new FormControl('', [Validators.required], ),
phone: new FormControl('', [Validators.required], ),
email: new FormControl('', [Validators.required, Validators.email], ),
pixKey: new FormControl('', [Validators.required], ),
buyer: new FormControl('', [Validators.required], ), combobox
customerId: new FormControl('', [], ), combobox
sellerId: new FormControl('', [Validators.required], ), combobox
bank: new FormControl('', [], ),
agencia: new FormControl('', [], ),
conta: new FormControl('', [], ),
categoryId: new FormControl('', [], ),
observer1: new FormControl('', [], ),
observer2: new FormControl('', [], ),
formAddress: new FormGroup({
zipCode: new FormControl('', [Validators.required], ),
address: new FormControl('', [Validators.required], ),
number: new FormControl('', [Validators.required], ),
complement: new FormControl('', [], ),
neighborhood: new FormControl('', [Validators.required], ),
city: new FormControl('', [Validators.required], ),
state: new FormControl('', [Validators.required], ),
}),
-->

View File

@@ -0,0 +1,23 @@
.form-partner {
display: flex;
justify-content: center;
}
.wrap {
display: flex;
justify-content: space-between;
}
.wrap .arrival-date {
width: 90%;
margin-right: 18px;
}
.k-form {
width: 600px;
margin-top: 50px;
background-color: white;
padding: 25px;
}
label {
width: 100%;
}

View File

@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { PartnerComponent } from './partner.component';
describe('PartnerComponent', () => {
let component: PartnerComponent;
let fixture: ComponentFixture<PartnerComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ PartnerComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(PartnerComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -0,0 +1,297 @@
import { Component, OnDestroy, OnInit } from '@angular/core';
import { FormControl, FormGroup, Validators } from '@angular/forms';
import { ActivatedRoute, Router } from '@angular/router';
import { forkJoin, Observable, of, Subscription, throwError } from 'rxjs';
import { catchError, debounceTime, map, mergeMap, tap } from 'rxjs/operators';
import { CategoryPartner } from 'src/app/models/category-partner.model';
import { Customer } from 'src/app/models/customer.model';
import { Partner } from 'src/app/models/partner.model';
import { CustomerService } from 'src/app/services/customer.service';
import { LookupService } from 'src/app/services/lookup.service';
import { PartnerService } from 'src/app/services/partner.service';
import { ConsultaCepService } from 'src/app/shared/services/consulta-cep.service';
import { Seller } from '../../../models/seller.model';
@Component({
selector: 'app-partner',
templateUrl: './partner.component.html',
styleUrls: ['./partner.component.scss']
})
export class PartnerComponent implements OnInit, OnDestroy {
formPartner: FormGroup;
partnerData: Partner;
isloading: boolean;
errorObject: any;
subscriptionSeller: Subscription;
sellers: Seller[];
selectedSeller: Seller;
subscriptionCategory: Subscription;
categoryPartners: CategoryPartner[];
selectedCategory: CategoryPartner;
subscriptionPartner: Subscription;
loadingCustomer = false;
customer$: Observable<Customer[]>;
selectedCustomer: Customer;
showCommission = false;
constructor(
private cepService: ConsultaCepService,
private lookupService: LookupService,
private partnerService: PartnerService,
private activeRoute: ActivatedRoute,
private customerService: CustomerService,
private router: Router,
) {
this.formPartner = new FormGroup({
name: new FormControl('', [Validators.required, Validators.minLength(10)]),
cpf: new FormControl('', [Validators.required]),
type: new FormControl('', [Validators.required]),
rg: new FormControl('', [Validators.required]),
professionalNumber: new FormControl('', [Validators.required]),
phone: new FormControl('', [Validators.required]),
email: new FormControl('', [Validators.required, Validators.email]),
pixKey: new FormControl('', [Validators.required]),
buyer: new FormControl('', [Validators.required]),
customerId: new FormControl(null),
customer: new FormControl(null),
seller: new FormControl(null),
sellerId: new FormControl(null),
bank: new FormControl('', []),
agencia: new FormControl('', []),
conta: new FormControl('', []),
zipCode: new FormControl('', [Validators.required]),
address: new FormControl('', [Validators.required]),
number: new FormControl('', [Validators.required]),
complement: new FormControl('', []),
neighborhood: new FormControl('', [Validators.required]),
city: new FormControl('', [Validators.required]),
state: new FormControl('', [Validators.required]),
category: new FormControl(null),
categoryId: new FormControl('', []),
observer1: new FormControl('', []),
observer2: new FormControl('', []),
});
this.formPartner.controls.type.valueChanges.pipe(
debounceTime(100),
).subscribe(() => {
console.log('alterando tipo do parceiro');
this.filterCategory();
});
}
ngOnInit(): void {
const cpf = this.activeRoute.snapshot.paramMap.get('cpf');
if (cpf != null) {
this.subscriptionPartner = this.partnerService.getPartner(cpf)
.pipe(
tap((data) => this.partnerData = data),
mergeMap(result => this.lookupService.getSellers()),
tap((dataSeller) => this.sellers = dataSeller),
mergeMap(result => this.lookupService.getCategoryPartner()),
tap((dataCategory) => this.categoryPartners = dataCategory),
mergeMap(result => this.customerService.getCustomerByQuery('customerId', (this.partnerData.customerId ?? 0).toString())),
tap((resultApi) => {
console.log(resultApi);
const data: Customer[] = resultApi.data;
this.selectedCustomer = resultApi[0];
if (this.selectedCustomer != null) {
this.handleFilterCustomer(this.selectedCustomer.name);
}
}),)
.subscribe(result => {
this.selectedSeller = this.sellers.find(s => s.sellerId === this.partnerData.sellerId);
this.selectedCategory = this.categoryPartners.find(c => c.id === this.partnerData.categoryId);
this.populatePartner(this.partnerData);
this.showCommission = this.partnerData.type == "B";
});
}
}
ngOnDestroy(): void {
if (this.subscriptionSeller) {
this.subscriptionSeller.unsubscribe();
}
if (this.subscriptionCategory) {
this.subscriptionCategory.unsubscribe();
}
}
public submitForm(): void {
this.formPartner.markAllAsTouched();
console.log(this.formPartner.valid);
console.log(this.formPartner.errors);
// if (this.formPartner.valid) {
const data = JSON.stringify(this.formPartner.value);
const partner: Partner = JSON.parse(data);
console.log(JSON.stringify(partner));
this.partnerService.createOrReplace(this.formPartner.value).pipe(
tap(() => {
this.isloading = false;
this.router.navigate(['partner/list']);
}),
catchError((error) => {
this.isloading = false;
console.log(error);
return of(error);
})
).subscribe();
// }
console.log(JSON.stringify(this.formPartner.value));
}
public clearForm(): void {
this.formPartner.reset();
this.router.navigate(['partner/list']);
}
consultaCep() {
const cep = this.formPartner.get('zipCode').value;
if (cep != null && cep !== '') {
this.cepService.consultaCep(cep)
.subscribe(
dados => {
this.populateAddress(dados);
});
}
}
populateAddress(dadosCep: any) {
console.log(dadosCep);
this.formPartner.patchValue({
address: dadosCep.logradouro,
complement: dadosCep.complemento,
neighborhood: dadosCep.bairro,
city: dadosCep.localidade,
state: dadosCep.uf,
});
}
searchPartner() {
const serachText = this.formPartner.get('cpf').value;
this.partnerService.getPartner(serachText).pipe(
map(result => {
if (result != null) {
this.partnerData = result;
this.populatePartner(this.partnerData);
}
}),
tap(() => {
this.isloading = false;
}),
catchError(err => {
this.isloading = false;
this.errorObject = err;
return throwError(err);
})).subscribe();
}
populatePartner(data: Partner) {
this.formPartner.patchValue({
name: data.name,
cpf: data.cpf,
type: data.type,
rg: data.rg,
professionalNumber: data.professionalNumber,
phone: data.phone,
email: data.email,
buyer: (data.buyer === 'S' ? true : false),
pixKey: data.pixKey,
bank: data.bank,
agencia: data.agencia,
conta: data.conta,
zipCode: data.zipCode,
address: data.address,
number: data.number,
complement: data.complement,
neighborhood: data.neighborhood,
city: data.city,
state: data.state,
category: this.selectedCategory,
seller: this.selectedSeller,
observer1: data.observer1,
observer2: data.observer2,
customerId: data.customerId,
categoryId: data.categoryId,
sellerId: data.sellerId,
commission: data.commission,
});
if (this.selectedSeller != null) {
this.formPartner.patchValue({
seller: this.selectedSeller
});
}
if (this.selectedCategory != null) {
this.formPartner.patchValue({
category: this.selectedCategory
});
}
if (this.selectedCustomer != null) {
this.formPartner.patchValue({
customer: this.selectedCustomer
});
}
}
selectSeller(seller: any) {
this.selectedSeller = seller;
this.formPartner.patchValue({
sellerId: this.selectedSeller.sellerId,
});
}
selectCategory(category: any) {
this.selectedCategory = category;
this.formPartner.patchValue({
categoryId: this.selectedCategory.id,
});
}
handleFilterCustomer(value) {
if (value.length > 3) {
this.loadingCustomer = true;
this.customer$ = this.customerService.getCustomer(value);
this.customer$.pipe(
tap(() => this.loadingCustomer = false)
).subscribe((data) => console.log(data));
}
}
selectCustomer(customer: any) {
console.log(customer);
this.selectedCustomer = customer;
this.formPartner.patchValue({
customerId: this.selectedCustomer.customerId,
});
}
filterCategory() {
const categories = this.categoryPartners;
const partnerType = this.formPartner.get('type').value;
this.categoryPartners = categories.filter(c => c.partnerType === partnerType);
console.log(JSON.stringify(this.categoryPartners));
this.showCommission = partnerType == "B";
}
parceiroBellaObra() {
const typePartner = this.formPartner.get('type').value;
console.log(typePartner);
this.showCommission = typePartner == "B";
}
}

View File

@@ -0,0 +1,538 @@
<div class="d-flex flex-column wrapper">
<div class="filter">
<form class="k-form shadow bg-body rounded" [formGroup]="formFilter">
<h4>FILTRO DE PARCEIROS</h4>
<label>
<span>CPF</span>
<kendo-textbox
formControlName="cpf"
placeholder="Informe o CPF do parceiro"
></kendo-textbox>
</label>
<label class="mt-2">
<span>Nome</span>
<kendo-textbox
formControlName="name"
placeholder="Informe o nome do parceiro"
></kendo-textbox>
</label>
<div class="row mt-2">
<div class="col-12">
<span>Tipo de parceiro</span>
</div>
<div class="col-sm-12 col-md-4 col-lg-2">
<label>
<input
type="radio"
name="type"
value="P"
#other
formControlName="type"
kendoRadioButton
/>
<span class="in-line">Parceiros</span>
</label>
</div>
<div class="col-sm-12 col-md-4 col-lg-2">
<label>
<input
type="radio"
name="type"
value="B"
#other
formControlName="type"
kendoRadioButton
/>
<span class="in-line">Bella Obra</span>
</label>
</div>
<div class="col-sm-12 col-md-4 col-lg-3">
<label>
<input
type="radio"
name="type"
value="M"
#other
formControlName="type"
kendoRadioButton
/>
<span class="in-line">Mestre Jurunense</span>
</label>
</div>
<div class="col-sm-12 col-md-4 col-lg-2">
<label>
<input
type="radio"
name="type"
value="T"
#other
formControlName="type"
kendoRadioButton
/>
<span class="in-line">Todos</span>
</label>
</div>
</div>
<div class="mt-3 row-buttons">
<button
kendoButton
rounded="medium"
themeColor="primary"
(click)="getPartners()"
>
Pesquisar
</button>
<button
kendoButton
rounded="medium"
themeColor="waring"
(click)="open()"
>
Incluir
</button>
</div>
</form>
</div>
<main class="flex-fill">
<kendo-grid
[kendoGridBinding]="gridView"
class="gridPartners"
(edit)="editPartner($event)"
[sortable]="true"
[reorderable]="true"
[resizable]="true"
[columnMenu]="{ filter: true }"
>
<kendo-grid-column title="Código" field="id" width="80">
</kendo-grid-column>
<kendo-grid-column title="Tipo Parceiro" field="type" width="150">
</kendo-grid-column>
<kendo-grid-column title="Categoria" field="category" width="150">
</kendo-grid-column>
<kendo-grid-column title="CPF" field="cpf" width="150">
</kendo-grid-column>
<kendo-grid-column title="Nome" field="name" width="250">
</kendo-grid-column>
<kendo-grid-column
title="Telefone"
field="phone"
width="100"
></kendo-grid-column>
<kendo-grid-column title="Data Cadastro" field="createDate" width="100">
<ng-template kendoGridCellTemplate let-dataItem>
<span>{{ dataItem.createDate | date : "dd/MM/yyyy" }}</span>
</ng-template>
</kendo-grid-column>
<kendo-grid-column title="Func cadastro" field="userCreate" width="120">
</kendo-grid-column>
<kendo-grid-column title="Data Alteração" field="updateDate" width="100">
<ng-template kendoGridCellTemplate let-dataItem>
<span>{{ dataItem.updateDate | date : "dd/MM/yyyy" }}</span>
</ng-template>
</kendo-grid-column>
<kendo-grid-column title="Func Alteração" field="userUpdate" width="120">
</kendo-grid-column>
<kendo-grid-column title="Ações" [width]="60">
<ng-template kendoGridCellTemplate let-dataItem>
<div class="row g-2 justify-content-start">
<div class="col-3 me-2" kendoGridEditCommand>
<i class="bi bi-pencil text-success"></i>
</div>
</div>
</ng-template>
</kendo-grid-column>
<ng-template kendoGridNoRecordsTemplate>
<div>
<kendo-badge-container>
<kendo-icon name="user" size="large"></kendo-icon>
<kendo-badge position="inside" themeColor="error">
<kendo-icon name="close"></kendo-icon>
</kendo-badge>
</kendo-badge-container>
</div>
<p>
Não foram localizados parceiros com os filtros inforamdos, verifique a
pesquisa.
</p>
</ng-template>
</kendo-grid>
</main>
</div>
<kendo-window
*ngIf="opened"
autoFocusedElement="#cpf"
title="CADASTRO DE PROFISSIONAL"
(close)="close()"
[minWidth]="250"
[width]="650"
[height]="650"
>
<form class="k-form" [formGroup]="formPartner">
<kendo-formfield>
<label>
<span>CPF</span>
<kendo-textbox
formControlName="cpf"
[clearButton]="true"
#cpf
(blur)="searchPartner()"
></kendo-textbox>
</label>
<kendo-formerror>Error: CPF é obrigatório</kendo-formerror>
</kendo-formfield>
<kendo-formfield>
<label>
<span>Nome</span>
<input
class="inputText"
formControlName="name"
#fullName
kendoTextBox
/>
</label>
<kendo-formerror>Error: Nome é obrigatório</kendo-formerror>
</kendo-formfield>
<kendo-formfield showHints="initial">
<label class="k-label">Tipo de parceiro</label>
<ul class="k-radio-list">
<li class="k-radio-item">
<label>
<input
type="radio"
#mestre
value="B"
kendoRadioButton
formControlName="type"
(change)="filterCategory('B')"
/>
<span> Bella Obra</span>
</label>
</li>
<li class="k-radio-item">
<label>
<input
type="radio"
#mestre
value="P"
kendoRadioButton
formControlName="type"
(change)="filterCategory('P')"
/>
<span> Parceiro</span>
</label>
</li>
<li class="k-radio-item">
<label>
<input
type="radio"
#parceiro
kendoRadioButton
value="M"
formControlName="type"
(change)="filterCategory('M')"
/>
<span> Mestre</span>
</label>
</li>
</ul>
<kendo-formerror *ngIf="formPartner.controls.type.errors?.required"
>Error: O tipo do parceiro é obrigatório</kendo-formerror
>
</kendo-formfield>
<kendo-formfield *ngIf="showCommission" showHints="initial">
<label>
<span class="d-block">Comissão (%)</span>
<input
*ngIf="!inputPercentPartner()"
[readOnly]="!inputPercentPartner()"
disabled="!inputPercentPartner()"
formControlName="commission"
type="number"
kendoNumericTextBox
/>
<input
*ngIf="inputPercentPartner()"
formControlName="commission"
type="number"
kendoNumericTextBox
/>
</label>
</kendo-formfield>
<kendo-formfield showHints="initial">
<label>
<input
kendoCheckBox
id="terms"
type="checkbox"
formControlName="buyer"
/>
<span class="ms-2">Parceiro é comprador de cliente PJ?</span>
</label>
</kendo-formfield>
<kendo-formfield>
<label>
<span>Cliente</span>
<kendo-combobox
textField="name"
valueField="customerId"
formControlName="customer"
[data]="customer$ | async"
[loading]="loadingCustomer"
[filterable]="true"
(filterChange)="handleFilterCustomer($event)"
placeholder="Selecione o cliente..."
(selectionChange)="selectCustomer($event)"
>
</kendo-combobox>
</label>
</kendo-formfield>
<kendo-formfield>
<label>
<span>Email</span>
<input formControlName="email" class="inputEmail" kendoTextBox #email />
</label>
<kendo-formerror *ngIf="formPartner.controls.type.errors?.required"
>Error: Email is required</kendo-formerror
>
<kendo-formerror *ngIf="formPartner.controls.email.errors?.email"
>Error: Not valid email format</kendo-formerror
>
</kendo-formfield>
<kendo-formfield>
<label>
<span>RG</span>
<kendo-textbox
formControlName="rg"
[clearButton]="true"
#rg
></kendo-textbox>
</label>
<kendo-formerror *ngIf="formPartner.controls.rg.errors?.rg"
>Error: RG é obrigaário</kendo-formerror
>
</kendo-formfield>
<kendo-formfield>
<label>
<span>Registro Profissional</span>
<kendo-textbox
formControlName="professionalNumber"
[clearButton]="true"
#professionalnumber
></kendo-textbox>
</label>
</kendo-formfield>
<kendo-formfield>
<label>
<span>Telefone (Whatsapp)</span>
<kendo-textbox
formControlName="phone"
[clearButton]="true"
#phone
></kendo-textbox>
</label>
</kendo-formfield>
<kendo-formfield>
<label>
<span>Chave PIX</span>
<kendo-textbox
formControlName="pixKey"
[clearButton]="true"
#pixKey
></kendo-textbox>
</label>
</kendo-formfield>
<kendo-formfield>
<label>
<span>Vendedor</span>
<kendo-combobox
textField="name"
valueField="sellerId"
formControlName="seller"
[data]="sellers$ | async"
[kendoDropDownFilter]="{ operator: 'contains' }"
placeholder="Selecione o vendedor que indicou o parceiro..."
(selectionChange)="selectSeller($event)"
>
</kendo-combobox>
</label>
</kendo-formfield>
<kendo-formfield>
<label>
<span>Categoria</span>
<kendo-combobox
textField="name"
valueField="id"
formControlName="category"
[data]="filterCategoryPartners"
[itemDisabled]="categoryDisabled"
[kendoDropDownFilter]="{ operator: 'contains' }"
placeholder="Selecione a categoria do parceiro..."
(selectionChange)="selectCategory($event)"
>
</kendo-combobox>
</label>
</kendo-formfield>
<h4 class="my-3">ENDEREÇO</h4>
<kendo-formfield>
<label>
<span>Cep</span>
<kendo-textbox
formControlName="zipCode"
[clearButton]="true"
#zipCode
(blur)="consultaCep()"
></kendo-textbox>
</label>
</kendo-formfield>
<kendo-formfield>
<label>
<span>Endereço</span>
<input formControlName="address" #address kendoTextBox />
</label>
</kendo-formfield>
<kendo-formfield>
<label>
<span>Número</span>
<kendo-textbox
formControlName="number"
[clearButton]="true"
#number
></kendo-textbox>
</label>
</kendo-formfield>
<kendo-formfield>
<label>
<span>Complemento</span>
<input formControlName="complement" kendoTextBox #complement />
</label>
</kendo-formfield>
<kendo-formfield>
<label>
<span>Bairro</span>
<input formControlName="neighborhood" kendoTextBox #neighborhood />
</label>
</kendo-formfield>
<kendo-formfield>
<label>
<span>Cidade</span>
<input formControlName="city" kendoTextBox #neighborhood />
</label>
</kendo-formfield>
<kendo-formfield>
<label>
<span>Estado</span>
<input formControlName="state" kendoTextBox #state />
</label>
</kendo-formfield>
<kendo-formfield>
<label>
<span>Praça</span>
<kendo-combobox
[data]="places$ | async"
formControlName="place"
[kendoDropDownFilter]="{ operator: 'contains' }"
textField="name"
valueField="id"
(selectionChange)="selectPlace($event)"
placeholder="Selecione a praça do parceiro..."
>
</kendo-combobox>
</label>
<kendo-formerror
>Erro: É obrigatório informar a praça do cliente</kendo-formerror
>
</kendo-formfield>
<h4 class="my-3">DADOS BANCÁRIOS</h4>
<div class="row">
<div class="col-12 col-sm-12 col-md-12 col-xl-4">
<kendo-formfield>
<label>
<span>Banco</span>
<kendo-textbox
formControlName="bank"
[clearButton]="true"
#bank
required
></kendo-textbox>
</label>
</kendo-formfield>
</div>
<div class="col-12 col-sm-12 col-md-12 col-xl-4">
<kendo-formfield>
<label>
<span>Agencia</span>
<kendo-textbox
formControlName="agencia"
[clearButton]="true"
#agencia
required
></kendo-textbox>
</label>
</kendo-formfield>
</div>
<div class="col-12 col-sm-12 col-md-4 col-xl-4">
<kendo-formfield>
<label>
<span>Conta</span>
<kendo-textbox
formControlName="conta"
[clearButton]="true"
#conta
required
></kendo-textbox>
</label>
</kendo-formfield>
</div>
</div>
<h4 class="my-3">OBSERVAÇÕES</h4>
<label>
<span>Observações</span>
<input formControlName="observer1" kendoTextBox #observer1 required />
</label>
<label>
<input formControlName="observer2" kendoTextBox #observer2 />
</label>
<div class="k-form-buttons">
<button
kendoButton
themeColor="primary"
(click)="submitForm()"
[disabled]="!formPartner.valid"
>
Salvar
</button>
<button kendoButton (click)="clearForm()">Cancelar</button>
</div>
</form>
</kendo-window>

View File

@@ -0,0 +1,49 @@
.wrapper {
min-height: calc(100vh - 80px);
}
.form-partner {
display: flex;
justify-content: start;
}
.gridPartners {
max-height: calc(100vh - 410px);
}
.wrap {
display: flex;
justify-content: space-between;
}
.wrap .arrival-date {
width: 90%;
margin-right: 18px;
}
.k-form {
width: 100%;
background-color: white;
padding: 25px;
}
label {
width: 100%;
}
input[type="radio"] {
margin-right: 16px;
vertical-align: text-bottom;
}
.row-buttons {
display: flex;
justify-content: start space-between;
}
.row-buttons button {
margin-right: 10px;
}
.inputText {
text-transform: uppercase;
}
.inputEmail {
text-transform: lowercase;
}

View File

@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { PartnersComponent } from './partners.component';
describe('PartnersComponent', () => {
let component: PartnersComponent;
let fixture: ComponentFixture<PartnersComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ PartnersComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(PartnersComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -0,0 +1,448 @@
import { Component, OnDestroy, OnInit, ViewChild } from '@angular/core';
import { FormGroup, FormControl, Validators } from '@angular/forms';
import { ActivatedRoute, Router } from '@angular/router';
import { Observable, of, Subscription, throwError } from 'rxjs';
import { PartnerService } from 'src/app/services/partner.service';
import { Partners } from 'src/app/models/partners.model';
import { ConsultaCepService } from 'src/app/shared/services/consulta-cep.service';
import { LookupService } from 'src/app/services/lookup.service';
import { CustomerService } from 'src/app/services/customer.service';
import { Partner } from 'src/app/models/partner.model';
import { Seller } from 'src/app/models/seller.model';
import { CategoryPartner } from 'src/app/models/category-partner.model';
import { Customer } from 'src/app/models/customer.model';
import { catchError, map, tap } from 'rxjs/operators';
import { PartnerCategoryService } from 'src/app/services/partner-category.service';
import { Place } from 'src/app/models/places.model';
import { DataBindingDirective } from '@progress/kendo-angular-grid';
import { process } from "@progress/kendo-data-query";
import { AuthService } from 'src/app/auth/services/auth.service';
@Component({
selector: 'app-partners',
templateUrl: './partners.component.html',
styleUrls: ['./partners.component.scss']
})
export class PartnersComponent implements OnInit, OnDestroy {
@ViewChild(DataBindingDirective) dataBinding: DataBindingDirective;
public gridView: unknown[];
formFilter: FormGroup;
partners$: Observable<Partners[]>;
partners: Partners[] = [];
formPartner: FormGroup;
partnerData: Partner;
isloading: boolean;
errorObject: any;
subscriptionSeller: Subscription;
sellers: Seller[];
selectedSeller: Seller;
sellers$: Observable<Seller[]>;
subscriptionCategory: Subscription;
categoryPartners: CategoryPartner[];
filterCategoryPartners: CategoryPartner[];
selectedCategory: CategoryPartner;
categoryPartners$: Observable<CategoryPartner[]>;
subscriptionPartner: Subscription;
loadingCustomer = false;
customer$: Observable<Customer[]>;
selectedCustomer: Customer;
places$: Observable<Place[]>;
subscriptionPlaces: Subscription;
places: Place[] = [];
selectedPlace: Place;
public opened = false;
partnerType = 'M';
showCommission = false;
constructor(
private readonly partnerService: PartnerService,
private route: ActivatedRoute,
private router: Router,
private cepService: ConsultaCepService,
private lookupService: LookupService,
private activeRoute: ActivatedRoute,
private customerService: CustomerService,
private readonly partnerCategoryService: PartnerCategoryService,
private readonly authService: AuthService,
) {
this.formFilter = new FormGroup({
cpf: new FormControl(null),
name: new FormControl(null),
type: new FormControl('T'),
});
this.formPartner = new FormGroup({
name: new FormControl('', [Validators.required]),
cpf: new FormControl('', [Validators.required]),
type: new FormControl('', [Validators.required]),
rg: new FormControl('', [Validators.required]),
professionalNumber: new FormControl('', [Validators.required]),
phone: new FormControl('', [Validators.required]),
email: new FormControl('', [Validators.required, Validators.email]),
pixKey: new FormControl(''),
buyer: new FormControl(''),
customerId: new FormControl(null),
customer: new FormControl(null),
seller: new FormControl(null),
sellerId: new FormControl(null),
bank: new FormControl('', []),
agencia: new FormControl('', []),
conta: new FormControl('', []),
zipCode: new FormControl('', [Validators.required]),
address: new FormControl('', [Validators.required]),
number: new FormControl('', [Validators.required]),
complement: new FormControl('', []),
neighborhood: new FormControl('', [Validators.required]),
city: new FormControl('', [Validators.required]),
state: new FormControl('', [Validators.required]),
ibgeCode: new FormControl('', []),
place: new FormControl(null, [Validators.required]),
placeId: new FormControl(null, []),
category: new FormControl(null),
categoryId: new FormControl('', []),
observer1: new FormControl(''),
observer2: new FormControl(''),
commission: new FormControl(''),
userId: new FormControl(''),
});
}
ngOnInit(): void {
this.categoryPartners$ = this.partnerCategoryService.getPartnerCategory('', 'T');
this.subscriptionCategory = this.categoryPartners$
.subscribe(data => {
this.categoryPartners = data;
this.filterCategoryPartners = data;
});
this.places$ = this.lookupService.getPlaces();
this.subscriptionPlaces = this.places$.subscribe(data => this.places = data);
this.sellers$ = this.lookupService.getSellers();
this.subscriptionSeller = this.sellers$.subscribe(data => this.sellers = data);
this.formPartner.valueChanges.subscribe(data => {
const type = this.formPartner.get('type').value;
this.showCommission = type == 'B';
});
}
ngOnDestroy(): void {
if (this.subscriptionPlaces){
this.subscriptionPlaces.unsubscribe();
}
if (this.subscriptionSeller){
this.subscriptionSeller.unsubscribe();
}
if (this.subscriptionCategory){
this.subscriptionCategory.unsubscribe();
}
if (this.subscriptionPartner){
this.subscriptionPartner.unsubscribe();
}
}
getPartners() {
const type = this.formFilter.get('type').value;
const cpf = this.formFilter.get('cpf').value;
const name = this.formFilter.get('name').value;
this.partners$ = this.partnerService.getPartnerByQuery(type, cpf, name);
this.subscriptionPartner = this.partners$.subscribe(data => {
this.partners = data;
console.log(data);
this.gridView = process(this.partners, {}).data;
this.dataBinding.skip = 0;
});
}
editPartner(data) {
console.log(data);
this.formPartner.reset();
const selectPartner = data.dataItem as Partner;
const serachText = data.dataItem.cpf;
this.partnerService.getPartner(serachText).pipe(
map(result => {
if (result != null) {
this.partnerData = result;
this.populatePartner(this.partnerData);
}
}),
tap(() => {
this.isloading = false;
this.opened = true;
}),
catchError(err => {
this.isloading = false;
this.errorObject = err;
return throwError(err);
})).subscribe();
}
open() {
this.formPartner.reset();
this.opened = true;
}
close() {
this.opened = false;
}
public submitForm(): void {
this.formPartner.markAllAsTouched();
console.log(this.formPartner.valid);
console.log(this.formPartner.errors);
const dataUser = localStorage.getItem('user');
const user = JSON.parse(dataUser);
this.formPartner.patchValue({
userId: user.id,
});
const data = JSON.stringify(this.formPartner.value);
console.log("DADOS DO FORMULARIO: " + data);
const partner: Partner = JSON.parse(data);
console.log(JSON.stringify(partner));
this.partnerService.createOrReplace(this.formPartner.value).pipe(
tap((resultData: Partner) => {
this.isloading = false;
this.opened = false;
const category = this.categoryPartners.find(c => c.id === resultData.categoryId);
const partnerData = new Partners();
partnerData.id = resultData.id;
partnerData.name = resultData.name;
partnerData.createDate = resultData.createDate;
partnerData.userCreate = resultData.userCreate;
partnerData.updateDate = resultData.updateDate;
partnerData.userUpdate = resultData.userUpdate;
if ( category != null) {
partnerData.category = category.name;
}
partnerData.cpf = resultData.cpf;
partnerData.phone = resultData.phone;
partnerData.type = (resultData.type === 'P') ? 'PARCEIRO' :
(resultData.type === 'M') ? 'MESTRE JURUNENSE' : (resultData.type === 'B') ? 'BELLA OBRA' : 'NÃO INFORMADO';
const partnerBD = this.partners.find(p => p.id === resultData.id);
const index = this.partners.indexOf(partnerBD);
if ( index === -1) {
this.partners.push(partnerData);
} else {
this.partners[index] = partnerData;
}
}),
catchError((error) => {
this.isloading = false;
console.log(error);
return of(error);
})
).subscribe();
// }
console.log(JSON.stringify(this.formPartner.value));
}
public clearForm(): void {
this.formPartner.reset();
this.opened = false;
}
consultaCep() {
const cep = this.formPartner.get('zipCode').value;
if (cep != null && cep !== '') {
this.cepService.consultaCep(cep)
.subscribe(
dados => {
this.populateAddress(dados);
});
}
}
populateAddress(dadosCep: any) {
console.log(dadosCep);
this.formPartner.patchValue({
address: dadosCep.logradouro,
complement: dadosCep.complemento,
neighborhood: dadosCep.bairro,
city: dadosCep.localidade,
state: dadosCep.uf,
ibgeCode: dadosCep.codigo_ibge,
});
console.log(JSON.stringify(this.formPartner.value));
}
searchPartner() {
const serachText = this.formPartner.get('cpf').value;
this.partnerService.getPartner(serachText).pipe(
map(result => {
if (result != null) {
this.partnerData = result;
this.populatePartner(this.partnerData);
}
}),
tap(() => {
this.isloading = false;
}),
catchError(err => {
this.isloading = false;
this.errorObject = err;
return throwError(err);
})).subscribe();
}
populatePartner(data: Partner) {
if ( data.sellerId != null) {
const sellerPartner = this.sellers.find(s => s.sellerId === data.sellerId);
if ( sellerPartner != null) {
this.selectedSeller = sellerPartner;
}
}
if ( data.categoryId != null) {
const category = this.categoryPartners.find(c => c.id === data.categoryId);
if ( category != null) {
this.selectedCategory = category;
}
}
if ( data.placeId != null) {
const place = this.places.find(p => p.id === data.placeId);
if ( place != null) {
this.selectedPlace = place;
}
}
this.filterCategory(data.type);
this.formPartner.patchValue({
name: data.name,
cpf: data.cpf,
type: data.type,
rg: data.rg,
professionalNumber: data.professionalNumber,
phone: data.phone,
email: data.email,
buyer: ( data.buyer === 'S' ? true : false ),
pixKey: data.pixKey,
bank: data.bank,
agencia: data.agencia,
conta: data.conta,
zipCode: data.zipCode,
ibgeCode: data.ibgeCode,
address: data.address,
number: data.number,
complement: data.complement,
neighborhood: data.neighborhood,
city: data.city,
state: data.state,
category: this.selectedCategory,
seller: this.selectedSeller,
place: this.selectedPlace,
observer1: data.observer1,
observer2: data.observer2,
customerId: data.customerId,
categoryId: data.categoryId,
sellerId: data.sellerId,
placeId: data.placeId,
commission: data.commission,
});
if ( this.selectedSeller != null) {
this.formPartner.patchValue({
seller: this.selectedSeller
});
}
if ( this.selectedCategory != null ) {
this.formPartner.patchValue({
category: this.selectedCategory
});
}
if ( this.selectedCustomer != null ) {
this.formPartner.patchValue({
customer: this.selectedCustomer
});
}
if ( this.selectedPlace != null ) {
this.formPartner.patchValue({
place: this.selectedPlace
});
}
}
selectSeller(seller: any) {
this.selectedSeller = seller;
this.formPartner.patchValue({
sellerId: this.selectedSeller.sellerId,
});
}
selectCategory(category: any) {
this.selectedCategory = category;
this.formPartner.patchValue({
categoryId: this.selectedCategory.id,
});
}
selectPlace(place: any) {
this.selectedPlace = place;
this.formPartner.patchValue({
placeId: this.selectedPlace.id,
});
}
handleFilterCustomer(value) {
if (value.length > 3) {
this.loadingCustomer = true;
this.customer$ = this.customerService.getCustomer(value);
this.customer$.pipe(
tap(() => this.loadingCustomer = false)
).subscribe((data) => console.log(data));
}
}
selectCustomer(customer: any) {
console.log(customer);
this.selectedCustomer = customer;
this.formPartner.patchValue({
customerId: this.selectedCustomer.customerId,
});
}
categoryDisabled(itemArgs: { dataItem: any; index: number }) {
return itemArgs.dataItem.partnerType === this.partnerType;
}
filterCategory(type: any) {
this.filterCategoryPartners = this.categoryPartners.filter(c => c.partnerType == type);
console.log(type + ' - ' + this.formPartner.get('commission').value);
if ( type == "B" && this.formPartner.get('commission').value == null) {
this.formPartner.patchValue({
commission: '4'
});
}
}
parceiroBellaObra() {
const typePartner = this.formPartner.get('type').value;
console.log(typePartner);
this.showCommission = typePartner == "B";
}
inputPercentPartner() {
console.log(this.authService.userAction(1, 1, 1));
return this.authService.userAction(1, 1, 1);
}
}

View File

@@ -0,0 +1,99 @@
<div class="container form-partner m-2">
<form class="k-form shadow bg-body rounded" [formGroup]="formPartner">
<legend>
<h5>CADASTRO DE CATEGORIA</h5>
</legend>
<kendo-formfield>
<label>
<span>Nome</span>
<kendo-textbox
formControlName="name"
[clearButton]="true"
#fullName
required
></kendo-textbox>
</label>
<kendo-formerror>Error: Nome é obrigatório</kendo-formerror>
</kendo-formfield>
<kendo-formfield showHints="initial">
<label class="k-label">Tipo de parceiro</label>
<ul class="k-radio-list">
<li class="k-radio-item">
<label>
<input
type="radio"
#mestre
value="P"
kendoRadioButton
formControlName="partnerType"
/>
<span> Parceiro</span>
</label>
</li>
<li class="k-radio-item">
<label>
<input
type="radio"
#parceiro
kendoRadioButton
value="M"
formControlName="partnerType"
/>
<span>Mestre Jurunense</span>
</label>
</li>
</ul>
<kendo-formerror *ngIf="formPartner.controls.partnerType.errors?.required"
>Error: O tipo do parceiro é obrigatório</kendo-formerror
>
</kendo-formfield>
<kendo-formfield showHints="initial">
<label class="k-label">Tipo de Pagamento</label>
<ul class="k-radio-list">
<li class="k-radio-item">
<label>
<input
type="radio"
#mestre
value="C"
kendoRadioButton
formControlName="paymentType"
/>
<span>Crédito</span>
</label>
</li>
<li class="k-radio-item">
<label>
<input
type="radio"
#parceiro
kendoRadioButton
value="P"
formControlName="paymentType"
/>
<span>Contas a pagar</span>
</label>
</li>
</ul>
<kendo-formerror *ngIf="formPartner.controls.paymentType.errors?.required"
>Error: O tipo do parceiro é obrigatório</kendo-formerror
>
</kendo-formfield>
<div class="k-form-buttons">
<button kendoButton themeColor="primary" (click)="submitForm()">
Send Reservation Request
</button>
<button kendoButton (click)="clearForm()">Clear</button>
</div>
</form>
</div>

View File

@@ -0,0 +1,22 @@
.form-partner {
display: flex;
justify-content: center;
}
.wrap {
display: flex;
justify-content: space-between;
}
.wrap .arrival-date {
width: 90%;
margin-right: 18px;
}
.k-form {
width: 600px;
margin-top: 50px;
background-color: white;
padding: 25px;
}
label {
width: 100%;
}

View File

@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ParnterCategoryCreateComponent } from './parnter-category-create.component';
describe('ParnterCategoryCreateComponent', () => {
let component: ParnterCategoryCreateComponent;
let fixture: ComponentFixture<ParnterCategoryCreateComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ParnterCategoryCreateComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ParnterCategoryCreateComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -0,0 +1,102 @@
import { Component, OnDestroy, OnInit } from '@angular/core';
import { FormControl, FormGroup, Validators } from '@angular/forms';
import { ActivatedRoute, Router } from '@angular/router';
import { Observable, of, Subscription } from 'rxjs';
import { catchError, tap } from 'rxjs/operators';
import { PartnerCategory } from 'src/app/models/partner-category.model';
import { PartnerCategoryService } from 'src/app/services/partner-category.service';
@Component({
selector: 'app-parnter-category-create',
templateUrl: './parnter-category-create.component.html',
styleUrls: ['./parnter-category-create.component.scss']
})
export class ParnterCategoryCreateComponent implements OnInit, OnDestroy {
formPartner: FormGroup;
partnerCategory$: Observable<PartnerCategory[]>;
partnerCategoryData: PartnerCategory;
subscriptionPartnerCategory: Subscription;
isloading: boolean;
errorObject: any;
constructor(
private partnerCategoryService: PartnerCategoryService,
private activeRoute: ActivatedRoute,
private router: Router,
) {
this.formPartner = new FormGroup({
id: new FormControl(),
name: new FormControl('', [Validators.required, Validators.minLength(10)]),
partnerType: new FormControl('', [Validators.required]),
paymentType: new FormControl('', [Validators.required]),
descriptionType: new FormControl(''),
descriptionPayment: new FormControl('')
});
}
ngOnInit(): void {
const id = this.activeRoute.snapshot.paramMap.get('id');
if (id != null) {
this.subscriptionPartnerCategory = this.partnerCategoryService.getPartnerCategoryById(id)
.subscribe(result => {
console.log(result);
this.partnerCategoryData = result;
this.populatePartnerCategory(this.partnerCategoryData);
});
}
}
ngOnDestroy(): void {
if (this.subscriptionPartnerCategory) {
this.subscriptionPartnerCategory.unsubscribe();
}
}
public submitForm(): void {
this.formPartner.markAllAsTouched();
console.log(this.formPartner.valid);
console.log(this.formPartner.errors);
// if (this.formPartner.valid) {
const data = JSON.stringify(this.formPartner.value);
const partner: PartnerCategory = JSON.parse(data);
console.log(JSON.stringify(partner));
this.partnerCategoryService.createOrReplace(this.formPartner.value).pipe(
tap(() => {
this.isloading = false;
// TODO: INCLUIR MENSAGEM
this.router.navigate(['/partner/category/home/category']);
}),
catchError((error) => {
this.isloading = false;
// TODO: INCLUIR MENSAGEM
console.log(error);
return of(error);
})
).subscribe();
console.log(JSON.stringify(this.formPartner.value));
}
public clearForm(): void {
this.formPartner.reset();
}
populatePartnerCategory(data: PartnerCategory) {
this.formPartner.patchValue({
id: data.id,
name: data.name,
partnerType: data.partnerType,
paymentType: data.paymentType,
descriptionType: data.descriptionType,
descriptionPayment: data.descriptionPayment,
});
}
}

View File

@@ -0,0 +1,254 @@
<div class="d-flex flex-column wrapper">
<div class="filter">
<form class="k-form shadow bg-body rounded" [formGroup]="formFilter">
<h4>FILTRO DE CATEGORIAS</h4>
<label class="mt-2">
<span>Descrição</span>
<kendo-textbox
formControlName="description"
placeholder="Informe o nome do parceiro"
></kendo-textbox>
</label>
<div class="row mt-2">
<div class="col-12">
<span>Tipo de parceiro</span>
</div>
<div class="col-sm-12 col-md-4 col-lg-2">
<label>
<input
type="radio"
name="type"
value="B"
#other
formControlName="type"
kendoRadioButton
/>
<span class="in-line"> Bella Obra</span>
</label>
</div>
<div class="col-sm-12 col-md-4 col-lg-2">
<label>
<input
type="radio"
name="type"
value="P"
#other
formControlName="type"
kendoRadioButton
/>
<span class="in-line"> Parceiros</span>
</label>
</div>
<div class="col-sm-12 col-md-4 col-lg-3">
<label>
<input
type="radio"
name="type"
value="M"
#other
formControlName="type"
kendoRadioButton
/>
<span class="in-line"> Mestre Jurunense</span>
</label>
</div>
<div class="col-sm-12 col-md-4 col-lg-2">
<label>
<input
type="radio"
name="type"
value="T"
#other
formControlName="type"
kendoRadioButton
/>
<span class="in-line"> Todos</span>
</label>
</div>
</div>
<div class="mt-3 row-buttons">
<button
kendoButton
rounded="medium"
themeColor="primary"
(click)="getPartnerCategory()"
>
Pesquisar
</button>
<button
kendoButton
rounded="medium"
themeColor="waring"
(click)="open(null)"
>
Incluir
</button>
</div>
</form>
</div>
<main class="flex-fill mt-3">
<kendo-grid
[kendoGridBinding]="gridView"
class="gridPartnerCategory"
(edit)="open($event)"
[sortable]="true"
[reorderable]="true"
[resizable]="true"
[columnMenu]="{ filter: true }"
>
<kendo-grid-column title="Código" field="id" width="80">
</kendo-grid-column>
<kendo-grid-column
title="Tipo Parceiro"
field="descriptionType"
width="100"
>
</kendo-grid-column>
<kendo-grid-column
title="Forma de Pagamento"
field="descriptionPayment"
width="100"
>
</kendo-grid-column>
<kendo-grid-column title="Descrição" field="name" width="250">
</kendo-grid-column>
<kendo-grid-column title="Ações" [width]="60">
<ng-template kendoGridCellTemplate let-dataItem>
<div class="row g-2 justify-content-start">
<div class="col-3 me-2" kendoGridEditCommand>
<i class="bi bi-pencil text-success"></i>
</div>
</div>
</ng-template>
</kendo-grid-column>
<ng-template kendoGridNoRecordsTemplate>
<div>
<kendo-badge-container>
<kendo-icon name="user" size="large"></kendo-icon>
<kendo-badge position="inside" themeColor="error">
<kendo-icon name="close"></kendo-icon>
</kendo-badge>
</kendo-badge-container>
</div>
<p>
Não foram localizadas categorias com os filtros inforamdos, verifique
a pesquisa.
</p>
</ng-template>
</kendo-grid>
</main>
</div>
<kendo-window
*ngIf="opened"
autoFocusedElement="#firstName"
title="CADASTRO DE CATEGORIA"
(close)="close()"
[minWidth]="250"
[width]="450"
>
<form class="k-form" [formGroup]="formPartner">
<kendo-formfield>
<label>
<span>Nome</span>
<kendo-textbox
formControlName="name"
[clearButton]="true"
#fullName
required
></kendo-textbox>
</label>
<kendo-formerror>Error: Nome é obrigatório</kendo-formerror>
</kendo-formfield>
<kendo-formfield showHints="initial">
<label class="k-label">Tipo de parceiro</label>
<ul class="k-radio-list">
<li class="k-radio-item">
<label>
<input
type="radio"
#mestre
value="B"
kendoRadioButton
formControlName="partnerType"
/>
<span> Bella Obra</span>
</label>
</li>
<li class="k-radio-item">
<label>
<input
type="radio"
#mestre
value="P"
kendoRadioButton
formControlName="partnerType"
/>
<span> Parceiro</span>
</label>
</li>
<li class="k-radio-item">
<label>
<input
type="radio"
#parceiro
kendoRadioButton
value="M"
formControlName="partnerType"
/>
<span>Mestre Jurunense</span>
</label>
</li>
</ul>
<kendo-formerror *ngIf="formPartner.controls.partnerType.errors?.required"
>Error: O tipo do parceiro é obrigatório</kendo-formerror
>
</kendo-formfield>
<kendo-formfield showHints="initial">
<label class="k-label">Tipo de Pagamento</label>
<ul class="k-radio-list">
<li class="k-radio-item">
<label>
<input
type="radio"
#mestre
value="C"
kendoRadioButton
formControlName="paymentType"
/>
<span>Crédito</span>
</label>
</li>
<li class="k-radio-item">
<label>
<input
type="radio"
#parceiro
kendoRadioButton
value="P"
formControlName="paymentType"
/>
<span>Contas a pagar</span>
</label>
</li>
</ul>
<kendo-formerror *ngIf="formPartner.controls.paymentType.errors?.required"
>Error: O tipo do parceiro é obrigatório</kendo-formerror
>
</kendo-formfield>
<div class="k-form-buttons">
<button kendoButton themeColor="primary" (click)="submitForm()">
Salvar
</button>
<button kendoButton (click)="clearForm()">Cancelar</button>
</div>
</form>
</kendo-window>

View File

@@ -0,0 +1,37 @@
.wrapper {
min-height: calc(100vh - 80px);
}
.gridPartnerCatetgory {
max-height: calc(100vh - 410px);
}
.form-partner {
display: flex;
justify-content: start;
}
.wrap {
display: flex;
justify-content: space-between;
}
.wrap .arrival-date {
width: 90%;
margin-right: 18px;
}
.k-form {
width: 100%;
background-color: white;
padding: 25px;
}
label {
width: 100%;
}
.row-buttons {
display: flex;
justify-content: start space-between;
}
.row-buttons button {
margin-right: 10px;
}

View File

@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ParnterCategoryHomeComponent } from './parnter-category-home.component';
describe('ParnterCategoryHomeComponent', () => {
let component: ParnterCategoryHomeComponent;
let fixture: ComponentFixture<ParnterCategoryHomeComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ParnterCategoryHomeComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ParnterCategoryHomeComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -0,0 +1,155 @@
import { Component, OnDestroy, OnInit, ViewChild } from '@angular/core';
import { FormControl, FormGroup, Validators } from '@angular/forms';
import { ActivatedRoute, Router } from '@angular/router';
import { DataBindingDirective } from '@progress/kendo-angular-grid';
import { Observable, of, Subscription } from 'rxjs';
import { catchError, tap } from 'rxjs/operators';
import { CategoryPartner } from 'src/app/models/category-partner.model';
import { PartnerCategory } from 'src/app/models/partner-category.model';
import { PartnerCategoryService } from 'src/app/services/partner-category.service';
@Component({
selector: 'app-parnter-category-home',
templateUrl: './parnter-category-home.component.html',
styleUrls: ['./parnter-category-home.component.scss']
})
export class ParnterCategoryHomeComponent implements OnInit, OnDestroy {
@ViewChild(DataBindingDirective) dataBinding: DataBindingDirective;
public gridView: unknown[];
formFilter: FormGroup;
formPartner: FormGroup;
partnerCategory$: Observable<PartnerCategory[]>;
partnerCategories: PartnerCategory[] = [];
subscriptionCategory: Subscription;
isloading = false;
public opened = false;
constructor(
private readonly partnerCategoryService: PartnerCategoryService,
private route: ActivatedRoute,
private router: Router
) {
this.formFilter = new FormGroup({
description: new FormControl(null),
type: new FormControl(null),
});
this.formPartner = new FormGroup({
id: new FormControl(),
name: new FormControl('', [Validators.required, Validators.minLength(10)]),
partnerType: new FormControl('', [Validators.required]),
paymentType: new FormControl('', [Validators.required]),
descriptionType: new FormControl(''),
descriptionPayment: new FormControl('')
});
}
ngOnInit(): void {
}
ngOnDestroy(): void {
if ( this.subscriptionCategory ) {
this.subscriptionCategory.unsubscribe();
}
}
getPartnerCategory() {
const description = this.formFilter.get('description').value;
const type = this.formFilter.get('type').value;
this.partnerCategory$ = this.partnerCategoryService.getPartnerCategory(description, type);
this.subscriptionCategory = this.partnerCategory$.subscribe(partnerCategory => {
this.partnerCategories = partnerCategory;
this.gridView = this.partnerCategories;
});
}
editPartner(data) {
console.log(data);
this.router.navigate([`/partner/category/edit/category/${data.dataItem.id}`]);
}
createPartnerCategory() {
this.router.navigate([`/partner/category/create/category`]);
}
public submitForm(): void {
this.formPartner.markAllAsTouched();
console.log(this.formPartner.valid);
console.log(this.formPartner.errors);
// if (this.formPartner.valid) {
const data = JSON.stringify(this.formPartner.value);
const partnerCategory: PartnerCategory = JSON.parse(data);
console.log(JSON.stringify(partnerCategory));
this.partnerCategoryService.createOrReplace(this.formPartner.value).pipe(
tap((resultData: PartnerCategory) => {
this.isloading = false;
// TODO: INCLUIR MENSAGEM
this.opened = false;
const categoryBD = this.partnerCategories.find(p => p.id === resultData.id);
console.log('CategoryBD: ' + JSON.stringify(categoryBD));
const index = this.partnerCategories.indexOf(categoryBD);
console.log('Index ' + index);
const categoryData = new PartnerCategory();
categoryData.id = resultData.id;
categoryData.name = resultData.name;
categoryData.partnerType = resultData.partnerType;
categoryData.paymentType = resultData.paymentType;
categoryData.descriptionType = ( resultData.partnerType === 'P') ? 'PARCEIRO' :
( resultData.partnerType === 'B') ? 'BELLA OBRA' : 'MESTRE JURUNENSE';
categoryData.descriptionPayment = (resultData.paymentType === 'C') ? 'Crédito' : 'Contas a Pagar';
if ( index === -1) {
this.partnerCategories.push(categoryData);
} else {
this.partnerCategories[index] = categoryData;
}
}),
catchError((error) => {
this.isloading = false;
// TODO: INCLUIR MENSAGEM
console.log(error);
return of(error);
})
).subscribe();
console.log(JSON.stringify(this.formPartner.value));
}
public clearForm(): void {
this.formPartner.reset();
this.opened = false;
}
populatePartnerCategory(data: PartnerCategory) {
this.formPartner.patchValue({
id: data.id,
name: data.name,
partnerType: data.partnerType,
paymentType: data.paymentType,
descriptionType: data.descriptionType,
descriptionPayment: data.descriptionPayment,
});
}
public close(): void {
this.opened = false;
}
public open(data: any): void {
this.formPartner.reset();
if ( data != null) {
const categoryPartner = data.dataItem as PartnerCategory;
this.populatePartnerCategory(categoryPartner);
}
this.opened = true;
}
}

View File

@@ -0,0 +1,510 @@
<!--Navbar -->
<nav class="navbar navbar-expand-lg fixed-top">
<div class="container-fluid">
<!-- offcanvas trigger-->
<button
class="navbar-toggler"
type="button"
data-bs-toggle="offcanvas"
data-bs-target="#offcanvasExample"
aria-controls="offcanvasExample"
>
<span
class="navbar-toggler-icon"
data-bs-target="#offcanvasExample"
></span>
</button>
<!-- offcanvas trigger-->
<div style="height: 200px;">
<a class="navbar-brand" href="/#/menu">
<img class="w-100 h-100" src="assets/img/logo.svg" alt="" />
</a>
</div>
<button
class="navbar-toggler"
type="button"
data-bs-toggle="collapse"
data-bs-target="#navbarSupportedContent"
aria-controls="navbarSupportedContent"
aria-expanded="false"
aria-label="Toggle navigation"
>
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<!--form class="d-flex ms-auto">
<div class="input-group my-3 my-lg-0">
<input
class="form-control me-2"
type="search"
placeholder="Search"
aria-label="Search"
/>
<button class="btn btn-outline-success" type="submit">Search</button>
</div>
</form-->
<ul class="navbar-nav ms-auto mb-2 mb-lg-0">
<li class="nav-item dropdown">
<a
class="nav-link dropdown-toggle"
href="#"
id="navbarDropdown"
role="button"
data-bs-toggle="dropdown"
aria-expanded="false"
>
<i class="bi bi-person-fill"></i>
</a>
<ul
class="dropdown-menu dropdown-menu-end"
aria-labelledby="navbarDropdown"
>
<li><a class="dropdown-item" href="#">Action</a></li>
<li><a class="dropdown-item" href="#">Another action</a></li>
<li><hr class="dropdown-divider" /></li>
<li><a class="dropdown-item" href="#">Something else here</a></li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
<!-- Navbar -->
<!-- OffCanvas -->
<div
class="offcanvas offcanvas-start sidebar-nav text-light"
data-bs-backdrop="false"
data-bs-scroll="true"
tabindex="-1"
id="offcanvasExample"
aria-labelledby="offcanvasExampleLabel"
>
<div class="offcanvas-header mt-2">
<h5 class="offcanvas-title" id="offcanvasExampleLabel">Mestre Jurunense</h5>
</div>
<div class="offcanvas-body">
<ul class="navbar-nav">
<!--li class="nav-item">
<a
class="nav-link px-3 sidebar-link"
>
<span><i class="bi bi-graph-up-arrow me-2"></i></span>
<span>Dashboard</span>
</a>
</li-->
<li *ngIf="pagePartners || pageCategory || pageRange" class="nav-item">
<a
class="nav-link px-3 sidebar-link"
data-bs-toggle="collapse"
href="#collapseExample"
role="button"
aria-expanded="false"
aria-controls="collapseExample"
>
<span><i class="bi bi-shop me-2"></i></span>
<span>Cadastros</span>
<span class="right-icon ms-auto"
><i class="bi bi-chevron-down"></i
></span>
</a>
<div class="collapse" id="collapseExample">
<div>
<ul class="navbar-nav ps-3">
<li *ngIf="pagePartners">
<a href="/#/partner/list" class="nav-link px-3">
<span>Parceiros</span>
</a>
</li>
<li *ngIf="pageCategory">
<a href="/#/partner/category" class="nav-link px-3">
<span>Categoria</span>
</a>
</li>
<li *ngIf="pageRange">
<a href="/#/partner/range" class="nav-link px-3">
<span>Faixa de comissão</span>
</a>
</li>
</ul>
</div>
</div>
</li>
<li>
<ul class="navbar-nav">
<li *ngIf="pageReportComission" class="nav-item">
<a
class="nav-link px-3 sidebar-link"
data-bs-toggle="collapse"
href="#collapseregister"
role="button"
aria-expanded="false"
aria-controls="collapseregister"
>
<span><i class="bi bi-person-plus me-2"></i></span>
<span>Relatórios</span>
<span class="right-icon ms-auto"
><i class="bi bi-chevron-down"></i
></span>
</a>
<div class="collapse" id="collapseregister">
<div>
<ul class="navbar-nav ps-3">
<li *ngIf="pageReportComission">
<a
href="/#/partner/report/commission"
class="nav-link px-3"
>
<span>Vendas realizadas</span>
</a>
</li>
<li *ngIf="pageExtractPartner">
<a
href="/#/partner/report/extract"
class="nav-link px-3"
>
<span>Extrato</span>
</a>
</li>
</ul>
</div>
</div>
</li>
</ul>
<ul class="navbar-nav">
<li *ngIf="pagePaymentPartner" class="nav-item">
<a
class="nav-link px-3 sidebar-link"
data-bs-toggle="collapse"
href="#collapsemov"
role="button"
aria-expanded="false"
aria-controls="collapsemov"
>
<span><i class="bi bi-person-plus me-2"></i></span>
<span>Movimentação</span>
<span class="right-icon ms-auto"
><i class="bi bi-chevron-down"></i
></span>
</a>
<div class="collapse" id="collapsemov">
<div>
<ul class="navbar-nav ps-3">
<li *ngIf="pagePaymentPartner">
<a
href="/#/partner/payment"
class="nav-link px-3"
>
<span>Gerar Pagamentos</span>
</a>
</li>
</ul>
</div>
</div>
</li>
</ul>
</li>
</ul>
</div>
</div>
<!-- OffCanvas -->
<main class="mt-5 pt-3">
<div class="container-fluid p-2">
<router-outlet></router-outlet>
</div>
</main>
<!--div class="container-fluid my-0 p-0">
<nav
class="
navbar navbar-expand-md
flex-md-column flex-row
align-items-center
py-2
text-center
sticky-top
"
>
<div class="container-fluid my-0 p-0 sticky-top">
<a class="navbar-brand" href="#">
<svg
xmlns="http://www.w3.org/2000/svg"
width="230.247"
height="50.6"
viewBox="0 0 260.247 70.6"
>
<g
id="Grupo_3105"
data-name="Grupo 3105"
transform="translate(-720 -509)"
>
<g id="Grupo_2" data-name="Grupo 2" transform="translate(720 509)">
<path
id="Caminho_1"
data-name="Caminho 1"
d="M4.118,62.728A5.958,5.958,0,0,0,6.5,64.917a7.776,7.776,0,0,0,3.683.822,5.47,5.47,0,0,0,2.859-.685,6.025,6.025,0,0,0,1.891-1.777,8.772,8.772,0,0,0,1.142-2.326q.39-1.233.7-2.395L22.981,23.4H39.033L32.845,61.293a44.545,44.545,0,0,1-1.8,5.642,18.634,18.634,0,0,1-3.523,5.678,18.474,18.474,0,0,1-6.242,4.412A24.1,24.1,0,0,1,11.322,78.8a32.319,32.319,0,0,1-5.462-.445,46.443,46.443,0,0,1-5.179-1.2Z"
transform="translate(-0.681 -8.203)"
fill="#fff"
></path>
<path
id="Caminho_2"
data-name="Caminho 2"
d="M48.366,31.258,45.807,45.086a14.283,14.283,0,0,0-.349,2.679,2.091,2.091,0,0,0,.349,1.315,1.644,1.644,0,0,0,1.337.438,2.183,2.183,0,0,0,2.094-1.046,12.462,12.462,0,0,0,1.047-3.385l2.558-13.828h11.4L61.39,46.4a12.035,12.035,0,0,1-5.233,8.4A18.931,18.931,0,0,1,45.69,57.5q-5.873,0-8.837-2.265a7.582,7.582,0,0,1-2.967-6.4,11.447,11.447,0,0,1,.059-1.168q.057-.583.174-1.266l2.849-15.143Z"
transform="translate(2.993 -7.333)"
fill="#fff"
></path>
<path
id="Caminho_3"
data-name="Caminho 3"
d="M82.473,41.439q-.756-.34-1.57-.633a4.352,4.352,0,0,0-1.454-.292A5.481,5.481,0,0,0,76.8,41.1a5.071,5.071,0,0,0-1.715,1.461,7.524,7.524,0,0,0-1.018,1.948,12.739,12.739,0,0,0-.552,2.094L71.6,57.021H60.2L64.97,31.311H76.425l-1.57,4.918.117.1a11.9,11.9,0,0,1,3.692-3.945A9.418,9.418,0,0,1,84.1,30.776h.349Z"
transform="translate(5.905 -7.386)"
fill="#fff"
></path>
<path
id="Caminho_4"
data-name="Caminho 4"
d="M96.512,31.258,93.955,45.086a14.19,14.19,0,0,0-.349,2.679,2.084,2.084,0,0,0,.349,1.315,1.643,1.643,0,0,0,1.337.438,2.181,2.181,0,0,0,2.092-1.046,12.462,12.462,0,0,0,1.047-3.385l2.559-13.828h11.4L109.538,46.4a12.033,12.033,0,0,1-5.234,8.4,18.927,18.927,0,0,1-10.466,2.7q-5.874,0-8.839-2.265a7.584,7.584,0,0,1-2.965-6.4q0-.583.058-1.168t.174-1.266l2.85-15.143Z"
transform="translate(8.321 -7.333)"
fill="#fff"
></path>
<path
id="Caminho_5"
data-name="Caminho 5"
d="M121.978,36.083l.057.1a9.7,9.7,0,0,1,1.542-2,12.635,12.635,0,0,1,2.122-1.728,11.456,11.456,0,0,1,2.5-1.217,8.3,8.3,0,0,1,2.733-.462,8.924,8.924,0,0,1,3.226.511,5.36,5.36,0,0,1,2.094,1.387,5,5,0,0,1,1.105,2.046,9.366,9.366,0,0,1,.32,2.482,11.986,11.986,0,0,1-.087,1.413q-.088.731-.2,1.462l-3.14,16.944h-11.4l2.385-13a10.485,10.485,0,0,0,.174-1.046,8.429,8.429,0,0,0,.059-.95,2.249,2.249,0,0,0-.321-1.291,1.5,1.5,0,0,0-1.307-.463,2.205,2.205,0,0,0-2.239,1.218,15.442,15.442,0,0,0-.96,3.164l-2.268,12.368h-11.4l4.768-25.709h11.4Z"
transform="translate(11.081 -7.386)"
fill="#fff"
></path>
<path
id="Caminho_6"
data-name="Caminho 6"
d="M162.677,48.305a13.84,13.84,0,0,1-5.989,6.865,18.263,18.263,0,0,1-9.305,2.386,17.484,17.484,0,0,1-5.349-.731,10.65,10.65,0,0,1-3.78-2.045,8.059,8.059,0,0,1-2.239-3.14,10.9,10.9,0,0,1-.727-4.067,11.78,11.78,0,0,1,.088-1.412q.087-.73.2-1.509a16.96,16.96,0,0,1,1.948-5.282,16.78,16.78,0,0,1,3.6-4.407,17.261,17.261,0,0,1,11.543-4.187,13.3,13.3,0,0,1,5.873,1.144,9.509,9.509,0,0,1,3.663,3.043,9.254,9.254,0,0,1,1.4,2.97,12.541,12.541,0,0,1,.407,3.165,21.587,21.587,0,0,1-.145,2.507,25.718,25.718,0,0,1-.436,2.557H146.686q-.058.342-.088.682t-.028.73a3.728,3.728,0,0,0,.406,1.754,1.719,1.719,0,0,0,1.686.78,3.091,3.091,0,0,0,2.85-1.8ZM152.965,41a1.343,1.343,0,0,0,.059-.39v-.389a3.273,3.273,0,0,0-.465-1.7,1.863,1.863,0,0,0-1.744-.779,2.629,2.629,0,0,0-1.279.317,3.052,3.052,0,0,0-.961.8,4.361,4.361,0,0,0-.61,1.072A4.291,4.291,0,0,0,147.674,41Z"
transform="translate(14.213 -7.386)"
fill="#fff"
></path>
<path
id="Caminho_7"
data-name="Caminho 7"
d="M175.239,36.083l.057.1a9.67,9.67,0,0,1,1.543-2,12.582,12.582,0,0,1,2.121-1.728,11.441,11.441,0,0,1,2.5-1.217,8.285,8.285,0,0,1,2.732-.462,8.919,8.919,0,0,1,3.226.511,5.373,5.373,0,0,1,2.095,1.387,5.011,5.011,0,0,1,1.1,2.046,9.367,9.367,0,0,1,.32,2.482,11.983,11.983,0,0,1-.087,1.413q-.087.731-.2,1.462l-3.14,16.944h-11.4l2.385-13a10.182,10.182,0,0,0,.174-1.046,8.425,8.425,0,0,0,.059-.95,2.249,2.249,0,0,0-.321-1.291,1.5,1.5,0,0,0-1.307-.463,2.205,2.205,0,0,0-2.239,1.218,15.443,15.443,0,0,0-.96,3.164l-2.267,12.368h-11.4L165,31.311h11.4Z"
transform="translate(16.974 -7.386)"
fill="#fff"
></path>
<path
id="Caminho_8"
data-name="Caminho 8"
d="M191.086,47.769a9.759,9.759,0,0,0,2.24,1.8,5.623,5.623,0,0,0,2.994.876,4.085,4.085,0,0,0,1.54-.317,1.31,1.31,0,0,0,.9-1v-.244a1.188,1.188,0,0,0-.641-1,7.9,7.9,0,0,0-1.977-.8,22.373,22.373,0,0,1-2.617-1,9.351,9.351,0,0,1-2.121-1.315,5.851,5.851,0,0,1-1.425-1.729,4.763,4.763,0,0,1-.523-2.288c0-.194.009-.4.029-.609s.048-.446.087-.705a8.21,8.21,0,0,1,1.57-3.6,10.8,10.8,0,0,1,3.082-2.727,15.743,15.743,0,0,1,4.245-1.728,20.713,20.713,0,0,1,9.768-.049,18.056,18.056,0,0,1,4.246,1.534l-5.176,6.963q-.873-.778-1.89-1.534a4.034,4.034,0,0,0-2.471-.755,2.519,2.519,0,0,0-1.222.318,1.306,1.306,0,0,0-.7.948V39a1.105,1.105,0,0,0,.32.78,3.326,3.326,0,0,0,.785.609,7.057,7.057,0,0,0,.96.463c.329.13.63.243.9.341a15.387,15.387,0,0,1,4.419,2.239,4.543,4.543,0,0,1,1.8,3.847c0,.194-.01.4-.029.609s-.049.431-.087.656a8.652,8.652,0,0,1-1.745,3.872,11.922,11.922,0,0,1-3.255,2.823,15.688,15.688,0,0,1-4.246,1.729,19.246,19.246,0,0,1-4.71.584,20.478,20.478,0,0,1-5.611-.706,27.977,27.977,0,0,1-4.971-1.971Z"
transform="translate(19.776 -7.386)"
fill="#fff"
></path>
<path
id="Caminho_9"
data-name="Caminho 9"
d="M236.524,48.305a13.835,13.835,0,0,1-5.989,6.865,18.259,18.259,0,0,1-9.3,2.386,17.484,17.484,0,0,1-5.349-.731,10.64,10.64,0,0,1-3.78-2.045,8.059,8.059,0,0,1-2.239-3.14,10.9,10.9,0,0,1-.727-4.067,11.786,11.786,0,0,1,.088-1.412q.087-.73.2-1.509a17.016,17.016,0,0,1,1.948-5.282,16.807,16.807,0,0,1,3.605-4.407,17.261,17.261,0,0,1,11.543-4.187A13.3,13.3,0,0,1,232.4,31.92a9.506,9.506,0,0,1,3.662,3.043,9.207,9.207,0,0,1,1.4,2.97,12.491,12.491,0,0,1,.408,3.165,21.843,21.843,0,0,1-.145,2.507q-.147,1.243-.436,2.557H220.533q-.058.342-.088.682t-.028.73a3.728,3.728,0,0,0,.405,1.754,1.722,1.722,0,0,0,1.687.78,3.091,3.091,0,0,0,2.85-1.8Zm-9.71-7.3a1.383,1.383,0,0,0,.059-.39v-.389a3.273,3.273,0,0,0-.465-1.7,1.863,1.863,0,0,0-1.744-.779,2.636,2.636,0,0,0-1.281.317,3.048,3.048,0,0,0-.96.8,4.361,4.361,0,0,0-.61,1.072A4.292,4.292,0,0,0,221.522,41Z"
transform="translate(22.385 -7.386)"
fill="#fff"
></path>
<path
id="Caminho_10"
data-name="Caminho 10"
d="M37.494,22.3H21.116L23.089,9.717H39.467Z"
transform="translate(1.58 -9.717)"
fill="#ef7d00"
></path>
<g
id="Grupo_1"
data-name="Grupo 1"
transform="translate(64.066 56.235)"
>
<path
id="Caminho_11"
data-name="Caminho 11"
d="M60.329,60.528h4.356l-.663,4.19h2.772l.662-4.19h4.355L69.846,72.966H65.49l.683-4.322H63.4l-.683,4.322H58.364Z"
transform="translate(-58.364 -60.329)"
fill="#ef7d00"
></path>
<path
id="Caminho_12"
data-name="Caminho 12"
d="M85.916,66.8a7.694,7.694,0,0,1-7.888,6.384c-3.794,0-6.5-2.391-5.87-6.384a7.837,7.837,0,0,1,7.9-6.451C83.833,60.349,86.533,62.89,85.916,66.8Zm-9.215.067a1.887,1.887,0,0,0,1.947,2.391,2.726,2.726,0,0,0,2.7-2.391,1.922,1.922,0,0,0-1.943-2.426A2.783,2.783,0,0,0,76.7,66.866Z"
transform="translate(-56.848 -60.349)"
fill="#ef7d00"
></path>
<path
id="Caminho_13"
data-name="Caminho 13"
d="M89.755,60.528h4.651l.684,6.533h.116a15.687,15.687,0,0,1,.573-1.65l2.175-4.882h4.6l.08,12.438H98.265l.466-6.813h-.083a12.046,12.046,0,0,1-.492,1.237l-2.679,5.575h-2.64L92.052,67.7a8.132,8.132,0,0,1-.036-1.55h-.148c-.112.494-.225,1.006-.353,1.5l-1.367,5.312H85.777Z"
transform="translate(-55.331 -60.329)"
fill="#ef7d00"
></path>
<path
id="Caminho_14"
data-name="Caminho 14"
d="M105.37,60.528h8.363l-.536,3.4h-3.811l-.188,1.188h3.481l-.511,3.233h-3.481l-.193,1.221h3.943l-.538,3.4h-8.5Z"
transform="translate(-53.38 -60.329)"
fill="#ef7d00"
></path>
<path
id="Caminho_15"
data-name="Caminho 15"
d="M131.541,65.6a3.375,3.375,0,0,0-2.458-1.254,2.962,2.962,0,0,0-2.841,2.425,2.065,2.065,0,0,0,2.14,2.426,4.238,4.238,0,0,0,2.772-1.155l-.866,4.653a10.737,10.737,0,0,1-3.3.494,5.2,5.2,0,0,1-5.322-6.3,7.861,7.861,0,0,1,7.531-6.533,8.741,8.741,0,0,1,2.954.512Z"
transform="translate(-51.368 -60.349)"
fill="#ef7d00"
></path>
<path
id="Caminho_16"
data-name="Caminho 16"
d="M133.985,60.528h8.364l-.538,3.4H138l-.188,1.188h3.481l-.51,3.233H137.3l-.193,1.221h3.943l-.538,3.4h-8.5Z"
transform="translate(-50.214 -60.329)"
fill="#ef7d00"
></path>
<path
id="Caminho_17"
data-name="Caminho 17"
d="M144.395,60.528h4.339l2.969,6.9h.131a18.385,18.385,0,0,1,.121-3.168l.59-3.728h4.322L154.9,72.966h-4.323l-2.943-6.533H147.5a14.36,14.36,0,0,1-.112,2.491l-.64,4.042H142.43Z"
transform="translate(-49.062 -60.329)"
fill="#ef7d00"
></path>
<path
id="Caminho_18"
data-name="Caminho 18"
d="M157.643,60.528h9.5l-.639,4.042-2.473-.116-1.345,8.512h-4.52l1.346-8.512L157,64.57Z"
transform="translate(-47.449 -60.329)"
fill="#ef7d00"
></path>
<path
id="Caminho_19"
data-name="Caminho 19"
d="M168.482,60.528h8.364l-.538,3.4H172.5l-.188,1.188h3.481l-.51,3.233H171.8l-.193,1.221h3.943l-.538,3.4h-8.5Z"
transform="translate(-46.397 -60.329)"
fill="#ef7d00"
></path>
<path
id="Caminho_20"
data-name="Caminho 20"
d="M178.952,60.528h5.46c2.8,0,4.992,1.187,4.5,4.322a3.571,3.571,0,0,1-2.92,3.234l-.016.1a2.5,2.5,0,0,1,.642.742l2.067,4.042h-5.213l-1.348-3.992h-.082l-.631,3.992h-4.421Zm3.55,5.51h.314c.742,0,1.5-.116,1.648-1.04.151-.957-.506-1.073-1.282-1.073h-.347Z"
transform="translate(-45.238 -60.329)"
fill="#ef7d00"
></path>
</g>
</g>
</g>
</svg>
</a>
<button
class="navbar-toggler"
type="button"
data-bs-toggle="collapse"
data-bs-target="#nav"
aria-controls="nav"
aria-expanded="false"
aria-label="Toggle navigation"
>
<span class="navbar-toggler-icon"></span>
</button>
</div>
</nav>
<div class="row min-vh-100 flex-column flex-md-row">
<aside class="col-12 col-md-3 col-xl-2 p-0 bg-dark">
<nav
class="
navbar navbar-expand-md navbar-dark
bd-dark
flex-md-column flex-row
align-items-center
py-2
text-center
"
id="sidebar"
>
<div class="text-center p-3">
<img
src="https://impreza.us-themes.com/wp-content/uploads/paolo-bendandi-D-8XODEIr_s-unsplash.jpg"
alt="profile picture"
class="img-fluid rounded-circle my-4 p-1 d-none d-md-block shadow"
/>
<a href="#" class="navbar-brand mx-0 font-weight-bold text-nowrap"
>XcentPupil</a
>
</div>
<button
type="button"
class="navbar-toggler border-0 order-1"
data-bs-toggle="collapse"
data-bs-target="#nav"
aria-controls="nav"
aria-expanded="false"
aria-label="Toggle navigation"
>
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse order-last" id="nav">
<ul class="navbar-nav flex-column w-100 justify-content-center">
<li class="nav-item">
<a href="#" class="nav-link active"> Edit Profile</a>
</li>
<li class="nav-item">
<a href="#" class="nav-link"> Projects</a>
</li>
<li class="nav-item">
<a href="#" class="nav-link"> Tasks </a>
</li>
<li class="nav-item">
<a href="#" class="nav-link"> Users Info </a>
</li>
</ul>
</div>
</nav>
</aside>
<main class="col px-0 flex-grow-1 overflow-auto">
<div class="container py-3">
<router-outlet></router-outlet>
</div>
</main>
</div>
</!--div>
<!--div class="container-fluid">
<div class="row">
<div class="col-2">
<div class="d-line" style="width: 240px; left: -240;">
<div class="sidebar fixed">
<span class="fs-5 fw-semibold">MENU</span>
<ul class="list-unstyled ps-0">
<li class="mb-1">
<button class="btn btn-toggle align-items-center rounded collapsed" data-bs-toggle="collapse" data-bs-target="#home-collapse" aria-expanded="true">
Cadastro
</button>
<div class="collapse show" id="home-collapse">
<ul class="btn-toggle-nav list-unstyled fw-normal pb-1 small">
<li><a href="#" class="link-dark rounded">Clientes</a></li>
</ul>
</div>
</li>
<li class="border-top my-3"></li>
<li class="mb-1">
<button class="btn btn-toggle align-items-center rounded collapsed" data-bs-toggle="collapse" data-bs-target="#account-collapse" aria-expanded="false">
Tabelas auxiliares
</button>
<div class="collapse" id="account-collapse">
<ul class="btn-toggle-nav list-unstyled fw-normal pb-1 small">
<li><a href="#" class="link-dark rounded">Fidelidade</a></li>
</ul>
</div>
</li>
</ul>
</div>
</div>
</div>
<div class="col-10">
<router-outlet></router-outlet>
</div>
</div>
</div-->

View File

@@ -0,0 +1,64 @@
.navbar {
background: #131d52;
height: 60px;
}
#menu-vertical{
position:fixed;
z-index:999;
overflow:hidden;
padding:6px;
height: 100vh;
background: #131d52
}
:root {
--offcanvas-width: 270px;
--topNavbarHeight: 56px;
}
.sidebar-nav {
width: 270px;
background: #131d52
}
.sidebar-link {
display: flex;
align-items: center;
}
.sidebar-link .right-icon {
display: inline-flex;
transition: all ease 0.25s;
}
.sidebar-link[aria-expanded="true"] .right-icon {
transform: rotate(180deg);
}
li a {
text-decoration: none;
color: white;
}
@media (min-width: 992px) {
body {
overflow: auto !important;
}
main {
margin-left: 270px;
}
.offcanvas-backdrop::before{
display: none;
}
.sidebar-nav{
transform: none;
visibility: visible !important;
top: 56px;
height: calc(100% - 56px);
}
}

View File

@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { PartnerMenuComponent } from './partner-menu.component';
describe('PartnerMenuComponent', () => {
let component: PartnerMenuComponent;
let fixture: ComponentFixture<PartnerMenuComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ PartnerMenuComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(PartnerMenuComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -0,0 +1,75 @@
import { Component, OnInit } from '@angular/core';
import { map, switchMap } from 'rxjs/operators';
import { AuthService } from 'src/app/auth/services/auth.service';
import { ActionsUser } from 'src/app/models/actions-user.model';
import { PagesUser } from 'src/app/models/pages-user.model';
import { ShoppingService } from 'src/app/services/shopping.service';
@Component({
templateUrl: './partner-menu.component.html',
styleUrls: ['./partner-menu.component.scss']
})
export class PartnerMenuComponent implements OnInit {
status = false;
/* Header */
public userName: string;
public storeName: string;
pagesUser: PagesUser[];
/* Pages */
pagePartners = true;
pageCategory = true;
pageRange = true;
pageReportComission = true;
pagePaymentPartner = true;
pageExtractPartner = true;
constructor(
private authService: AuthService,
private shoppingService: ShoppingService,
) { }
ngOnInit(): void {
this.userName = this.authService.getUserName();
this.storeName = this.authService.getStoreName();
const sellerId = this.authService.getSeller();
this.authService.getPagesUser(2)
.pipe(
map((modules) => {
this.pagesUser = modules;
this.configPagesUser();
}),
switchMap((modules) => this.authService.getActionsUser(2)),
map((actions) => this.authService.actionsUser = actions))
.subscribe();
}
clickEvent() {
this.status = !this.status;
}
logout() {
this.shoppingService.cancelShopping();
this.authService.logout();
}
configPagesUser() {
this.pagePartners = this.pageEnable(1, 1);
this.pageCategory = this.pageEnable(1, 2);
this.pageRange = this.pageEnable(1, 3);
this.pageReportComission = this.pageEnable(2, 1);
this.pageExtractPartner = this.pageEnable(2, 2);
this.pagePaymentPartner = this.pageEnable(3, 1);
}
pageEnable(processId: number, pageId: number) {
const page = this.pagesUser.find(p => p.moduleId == 2 && p.processId == processId && p.pageId == pageId);
if (page === undefined) {
return false;
} else {
return page.access == 'S';
}
}
}

View File

@@ -0,0 +1,42 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { RouterModule, Routes } from '@angular/router';
import { PartnerComponent } from './create/partner/partner.component';
import { PartnersComponent } from './home/partners.component';
import { PartnerRangeComponent } from './range/partner-range/partner-range.component';
import { ParnterCategoryHomeComponent } from './parnter-category-home/parnter-category-home.component';
import { ParnterCategoryCreateComponent } from './parnter-category-create/parnter-category-create.component';
import { PartnerMenuComponent } from './partner-menu/partner-menu.component';
import { CommissionComponent } from './reports/commission/commission.component';
import { PaymentComponent } from './payment/payment.component';
import { ExtractPartnerComponent } from './reports/extract-partner/extract-partner.component';
const routes: Routes = [
{
path: '', component: PartnerMenuComponent,
children: [
{ path: 'list', component: PartnersComponent },
{ path: 'create', component: PartnerComponent },
{ path: 'category', component: ParnterCategoryHomeComponent },
{ path: 'payment', component: PaymentComponent },
{ path: 'report/commission', component: CommissionComponent },
{ path: 'category/create', component: ParnterCategoryCreateComponent },
{ path: 'category/edit/:id', component: ParnterCategoryCreateComponent },
{ path: 'range', component: PartnerRangeComponent },
{ path: 'edit/:cpf', component: PartnerComponent },
{ path: 'report/extract', component: ExtractPartnerComponent },
]
},
];
@NgModule({
declarations: [],
imports: [
CommonModule,
RouterModule.forChild(routes)
]
})
export class PartnerRoutingModule { }

View File

@@ -0,0 +1,47 @@
import { NgModule } from '@angular/core';
import { PartnerRoutingModule } from './partner-routing.module';
import { CommonModule } from '@angular/common';
import { PartnersComponent } from './home/partners.component';
import { PartnerComponent } from './create/partner/partner.component';
import { KendoModule } from '../shared/kendo.module';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { HttpClientModule } from '@angular/common/http';
import { PartnerRangeComponent } from './range/partner-range/partner-range.component';
import { ParnterCategoryCreateComponent } from './parnter-category-create/parnter-category-create.component';
import { ParnterCategoryHomeComponent } from './parnter-category-home/parnter-category-home.component';
import { PartnerMenuComponent } from './partner-menu/partner-menu.component';
import { ComponentModule } from '../components/component.module';
import { RouterModule } from '@angular/router';
import { CommissionComponent } from './reports/commission/commission.component';
import { StimulsoftViewerModule } from 'stimulsoft-viewer-angular';
import { PaymentComponent } from './payment/payment.component';
import { ConfirmationComponent } from '../shared/messages/confirmation/confirmation.component';
import { SharedModule } from '../shared/shared.module';
import { ExtractPartnerComponent } from './reports/extract-partner/extract-partner.component';
@NgModule({
declarations: [PartnersComponent, PartnerComponent,
ParnterCategoryHomeComponent, ParnterCategoryCreateComponent,
PartnerRangeComponent,
PartnerMenuComponent,
CommissionComponent,
PaymentComponent,
ExtractPartnerComponent],
imports: [
CommonModule,
KendoModule,
FormsModule,
ReactiveFormsModule,
PartnerRoutingModule,
HttpClientModule,
ComponentModule,
RouterModule,
StimulsoftViewerModule,
SharedModule,
]
})
export class PartnersModule { }

View File

@@ -0,0 +1,308 @@
<div class="d-flex flex-column wrapper">
<div class="filter">
<form [formGroup]="formFilter" class="k-form shadow bg-body rounded">
<h4>PAGAMENTO DE COMISSAO DE PARCEIROS</h4>
<div class="row">
<div class="col-12 col-sm-6 col-md-6 col-lg-6">
<label class="mt-3">
<span>Parceiro</span>
<kendo-combobox
#partner
[data]="partners$ | async"
textField="name"
valueField="id"
[kendoDropDownFilter]="{ operator: 'contains' }"
(selectionChange)="selectPartner($event)"
></kendo-combobox>
</label>
</div>
<div class="col-12 col-sm-6 col-md-6 col-lg-6">
<form [formGroup]="formFilter">
<div class="row mt-3">
<div class="col-12">
<span>Tipo de parceiro</span>
</div>
<div class="col-sm-12 col-md-3 col-lg-3">
<label>
<input
type="radio"
name="type"
value="B"
#other
formControlName="type"
kendoRadioButton
/>
<span class="in-line ms-2">Bella Obra</span>
</label>
</div>
<div class="col-sm-12 col-md-3 col-lg-3">
<label>
<input
type="radio"
name="type"
value="P"
#other
formControlName="type"
kendoRadioButton
/>
<span class="in-line ms-2">Parceiros</span>
</label>
</div>
<div class="col-sm-12 col-md-3 col-lg-3">
<label>
<input
type="radio"
name="type"
value="M"
#other
formControlName="type"
kendoRadioButton
/>
<span class="in-line ms-2">Mestre</span>
</label>
</div>
<div class="col-sm-12 col-md-3 col-lg-3">
<label>
<input
type="radio"
name="type"
value="T"
#other
formControlName="type"
kendoRadioButton
/>
<span class="in-line ms-2">Todos</span>
</label>
</div>
</div>
</form>
</div>
</div>
<div class="row mt-3">
<div class="col-6 col-sm-6 col-md-4 col-lg-3">
<label>
<span>Mês de apuração</span>
<kendo-datepicker
#shortDate
format="MMMM/yyyy"
[value]="value"
formControlName="dateMov"
activeView="year"
bottomView="year"
>
</kendo-datepicker>
</label>
</div>
</div>
<div class="mt-5 row-buttons">
<button
kendoButton
rounded="medium"
themeColor="primary"
(click)="search()"
>
Pesquisar
</button>
<button
class="ms-auto"
kendoButton
rounded="medium"
themeColor="primary"
(click)="showConfirmationPayment()"
>
Processar
</button>
</div>
</form>
</div>
<main class="flex-fill mt-3">
<kendo-grid
[kendoGridBinding]="gridView"
[height]="800"
[sortable]="true"
[filterable]="filterMode"
(pageChange)="pageChange($event)"
kendoGridSelectBy="partnerId"
[(selectedKeys)]="mySelection"
(groupChange)="onGroupChange($event)"
[groupable]="{ showFooter: true }"
[group]="group"
>
<ng-template kendoGridToolbarTemplate>
<button type="button" kendoGridExcelCommand icon="file-excel">
Export to Excel
</button>
</ng-template>
<kendo-grid-checkbox-column
[showSelectAll]="true"
[width]="50"
></kendo-grid-checkbox-column>
<kendo-grid-column
field="partnerId"
title="Código Parceiro"
[width]="80"
></kendo-grid-column>
<kendo-grid-column
field="name"
title="Nome"
[width]="230"
></kendo-grid-column>
<kendo-grid-column
field="type"
title="Tipo Parceiro"
[width]="120"
></kendo-grid-column>
<kendo-grid-column
field="phone"
title="Telefone"
[width]="110"
></kendo-grid-column>
<kendo-grid-column
field="saleValue"
title="Venda Líquida"
[width]="140"
[class]="{ 'text-end': true }"
>
<ng-template kendoGridCellTemplate let-dataItem>
<span>{{ dataItem.saleValue | currency }}</span>
</ng-template>
<ng-template kendoGridGroupFooterTemplate let-aggregates="aggregates">
<span> {{ aggregates.saleValue.sum | currency }} </span>
</ng-template>
</kendo-grid-column>
<kendo-grid-column
field="devolValue"
title="Devolução"
[width]="140"
[class]="{'text-end': true }"
>
<ng-template kendoGridCellTemplate let-dataItem>
<span>{{ dataItem.devolValue | currency }}</span>
</ng-template>
<ng-template kendoGridGroupFooterTemplate let-aggregates="aggregates">
<span> {{ aggregates.devolValue.sum | currency }} </span>
</ng-template>
</kendo-grid-column>
<kendo-grid-column
field="previusBalance"
title="Saldo Anterior"
[width]="140"
[class]="{ 'text-end': true }"
>
<ng-template kendoGridCellTemplate let-dataItem>
<span>{{ dataItem.previusBalance | currency }}</span>
</ng-template>
<ng-template kendoGridGroupFooterTemplate let-aggregates="aggregates">
<span> {{ aggregates.previusBalance.sum | currency }} </span>
</ng-template>
</kendo-grid-column>
<kendo-grid-column
field="commissionValue"
title="Valor da Comissão"
[width]="140"
[class]="{ 'text-end': true }"
><ng-template kendoGridCellTemplate let-dataItem>
<span>{{ dataItem.commissionValue | currency }}</span>
</ng-template>
<ng-template kendoGridGroupFooterTemplate let-aggregates="aggregates">
<span> {{ aggregates.commissionValue.sum | currency }} </span>
</ng-template>
</kendo-grid-column>
<kendo-grid-column
field="paidValue"
title="Valor Pago"
[width]="140"
[class]="{ 'text-end': true }"
><ng-template kendoGridCellTemplate let-dataItem>
<span>{{ dataItem.paidValue | currency }}</span>
</ng-template>
<ng-template kendoGridGroupFooterTemplate let-aggregates="aggregates">
<span> {{ aggregates.paidValue.sum | currency }} </span>
</ng-template>
</kendo-grid-column>
<kendo-grid-column
field="creditValue"
title="Valor Crédito"
[width]="140"
[class]="{ 'text-end': true }"
><ng-template kendoGridCellTemplate let-dataItem>
<span>{{ dataItem.creditValue | currency }}</span>
</ng-template>
<ng-template kendoGridGroupFooterTemplate let-aggregates="aggregates">
<span> {{ aggregates.creditValue.sum | currency }} </span>
</ng-template>
</kendo-grid-column>
<kendo-grid-column
field="balance"
title="Valor a pagar"
[width]="140"
[class]="{ 'text-end': true }"
><ng-template kendoGridCellTemplate let-dataItem>
<span>{{ dataItem.balance | currency }}</span>
</ng-template>
<ng-template kendoGridGroupFooterTemplate let-aggregates="aggregates">
<span> {{ aggregates.balance.sum | currency }} </span>
</ng-template>
</kendo-grid-column>
<kendo-grid-excel fileName="PagamentoParceiros.xlsx"></kendo-grid-excel>
</kendo-grid>
</main>
<div *ngIf="loading">
<div class="k-loading-panel">
<div class="k-loading-panel-mask"></div>
<div class="k-loading-panel-wrapper">
<div class="k-loading-panel-text text-center">
<kendo-loader
style="justify-content: center"
type="infinite-spinner"
themeColor="primary"
size="large"
>
</kendo-loader>
</div>
<div class="k-loading-panel-text text-center">
{{ messageLoading }}
</div>
</div>
</div>
</div>
</div>
<div *ngIf="openedConfirmationPayment">
<app-confirmation
opened="openedConfirmationPayment"
title="{{ titleMessage }}"
message="{{ messageConfirmation }}"
textButtonConfirmation="{{ textButtonConfirmation }}"
textButtonCancel="{{ textButtonCancel }}"
(resultEvent)="createPayment($event)"
></app-confirmation>
</div>
<div *ngIf="openedInformation">
<app-message-information
opened="openedConfirmationPayment"
title="{{ titleInformation }}"
message="{{ messageInformation }}"
></app-message-information>
</div>
<div *ngIf="openedInformation">
<app-message-information
opened="true"
title="Autorização de desconto"
message="{{ messageInformation }}"
(resultEvent)="closeInformation($event)"
></app-message-information>
</div>

View File

@@ -0,0 +1,37 @@
.wrapper {
min-height: calc(100vh - 80px);
}
.gridPartnerCatetgory {
max-height: calc(100vh - 410px);
}
.form-partner {
display: flex;
justify-content: start;
}
.wrap {
display: flex;
justify-content: space-between;
}
.wrap .arrival-date {
width: 90%;
margin-right: 18px;
}
.k-form {
width: 100%;
background-color: white;
padding: 25px;
}
label {
width: 100%;
}
.row-buttons {
display: flex;
justify-content: start space-between;
}
.row-buttons button {
margin-right: 10px;
}

View File

@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { PaymentComponent } from './payment.component';
describe('PaymentComponent', () => {
let component: PaymentComponent;
let fixture: ComponentFixture<PaymentComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ PaymentComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(PaymentComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -0,0 +1,203 @@
import { Component, OnInit, ViewChild } from '@angular/core';
import { FormControl, FormGroup } from '@angular/forms';
import { DataBindingDirective, FilterableSettings, GridDataResult } from '@progress/kendo-angular-grid';
import { AggregateDescriptor, groupBy, GroupDescriptor, process } from "@progress/kendo-data-query";
import { PageChangeEvent } from '@progress/kendo-angular-pager';
import { Observable, of } from 'rxjs';
import { catchError, map, tap } from 'rxjs/operators';
import { AuthService } from 'src/app/auth/services/auth.service';
import { CreatePaymentPartner } from 'src/app/models/create-payment-partner.model';
import { Partners } from 'src/app/models/partners.model';
import { PaymentPartner } from 'src/app/models/payment-partner.model';
import { PartnerService } from 'src/app/services/partner.service';
@Component({
selector: 'app-payment',
templateUrl: './payment.component.html',
styleUrls: ['./payment.component.scss']
})
export class PaymentComponent implements OnInit {
formFilter: FormGroup;
type: FormControl;
partners$: Observable<Partners[]>;
selectedPartner: Partners;
public value: Date = new Date();
@ViewChild(DataBindingDirective) dataBinding: DataBindingDirective;
titleMessage = 'Confirmar';
messageConfirmation = 'Confirma processamento?';
textButtonConfirmation = 'OK';
textButtonCancel = 'Cancelar';
openedConfirmationPayment = false;
loading = false;
messageLoading = 'Aguarde, consultando vendas dos parceiros...';
openedInformation = false;
titleInformation = 'Pagamento de parceiros';
messageInformation = '';
public gridView: any; // GridDataResult;
public paymentsPartner: PaymentPartner[] = [];
public mySelection: number[] = [];
public pageSize = 30;
public skip = 0;
public filterMode: FilterableSettings = "row";
public myAggregates: AggregateDescriptor[] = [
{ field: 'saleValue', aggregate: 'sum' },
{ field: 'devolValue', aggregate: 'sum' },
{ field: 'commissionValue', aggregate: 'sum' },
{ field: 'previusBalance', aggregate: 'sum' },
{ field: 'paidValue', aggregate: 'sum' },
{ field: 'creditValue', aggregate: 'sum' },
{ field: 'balance', aggregate: 'sum' },
];
public group: GroupDescriptor[] = [
{ field: "type", aggregates: this.myAggregates },
];
constructor(
private readonly partnerService: PartnerService,
private readonly authService: AuthService,
) { }
ngOnInit(): void {
this.partners$ = this.partnerService.getPartnerByQuery('T', null, null);
this.formFilter = new FormGroup({
type: new FormControl(),
dateMov: new FormControl(),
});
}
public selectPartner(partner: any) {
console.log(partner);
this.selectedPartner = null;
if (partner) {
this.selectedPartner = partner;
}
}
public pageChange(event: PageChangeEvent): void {
this.skip = event.skip;
this.loadItems();
}
private loadItems(): void {
// this.gridView = {
// data: this.paymentsPartner.slice(this.skip, this.skip + this.pageSize),
// total: this.paymentsPartner.length,
// };
this.gridView = groupBy(process(this.paymentsPartner, {}).data, this.group);
this.dataBinding.skip = 0;
this.mySelection = [];
}
public onGroupChange(group: GroupDescriptor[]): void {
// set aggregates to the returned GroupDescriptor
group.map((group) => (group.aggregates = this.myAggregates));
this.group = group;
this.loadItems();
}
public search() {
let partnerId = -1;
if (this.selectedPartner !== null && this.selectedPartner !== undefined) {
partnerId = this.selectedPartner.id;
}
const dateMov = this.formFilter.get('dateMov').value as Date;
const month = ('00' + (dateMov.getMonth() + 1)).slice(-2);
const year = dateMov.getFullYear();
const type = this.formFilter.get('type').value;
let intType = 99;
switch (type) {
case 'M':
intType = 1;
break;
case 'P':
intType = 2;
break;
case 'B':
intType = 3;
break;
default:
intType = 99;
break;
}
console.log(type);
this.messageLoading = 'Aguarde, consultando vendas dos parceiros...';
this.loading = true;
this.partnerService.getPayment(partnerId, intType, month, year.toString()).pipe(
map(data => {
this.paymentsPartner = data;
console.log(data);
this.loadItems();
this.loading = false;
}),
catchError(error => {
this.loading = false;
this.messageInformation = error.message;
this.openedInformation = true;
return of();
})
).subscribe();
}
async showConfirmationPayment() {
this.titleMessage = 'Gerar pagamentos parceiros';
this.messageConfirmation = `Confirma a geração dos pagamentos?`;
this.textButtonConfirmation = 'Confirma';
this.openedConfirmationPayment = true;
}
createPayment(result: any) {
console.log(result);
this.openedConfirmationPayment = false;
const payments: CreatePaymentPartner[] = [];
const dateMov = this.formFilter.get('dateMov').value as Date;
const month = ('00' + (dateMov.getMonth() + 1)).slice(-2);
const year = dateMov.getFullYear();
this.mySelection.forEach(partnerId => {
const payment = new CreatePaymentPartner();
payment.dueDate = new Date(year, Number.parseInt(month), 10);
payment.month = month;
payment.partnerId = partnerId;
payment.userId = this.authService.getUser();
payment.year = year.toString();
payments.push(payment);
});
console.log(JSON.stringify(payments));
this.messageLoading = 'Aguarde, processando pagamentos dos parceiros selecionados...';
this.loading = true;
this.partnerService.createPayment(payments).pipe(
tap(() => {
this.loading = false;
this.search();
}),
catchError(error => {
this.loading = false;
this.messageInformation = error.message;
this.openedInformation = true;
return of();
})
)
.subscribe();
}
closeInformation(result: any) {
this.openedInformation = false;
}
}

View File

@@ -0,0 +1,444 @@
<div class="d-flex flex-column wrapper">
<div class="filter">
<form class="k-form shadow bg-body rounded" [formGroup]="formFilter">
<h4>FAIXA DE COMISSÃO PARCEIROS</h4>
<div class="row mt-2">
<form [formGroup]="formFilter">
<fieldset class="k-form-fieldset">
<label>
<span>Tipo do parceiro</span>
<ul class="k-radio-list k-list-horizontal">
<li class="k-radio-item">
<label>
<input
type="radio"
value="B"
kendoRadioButton
formControlName="typeFilter"
/>
<span> Bella Obra</span>
</label>
</li>
<li class="k-radio-item">
<label>
<input
type="radio"
value="P"
kendoRadioButton
formControlName="typeFilter"
/>
<span> Parceiro</span>
</label>
</li>
<li class="k-radio-item">
<label>
<input
type="radio"
kendoRadioButton
value="M"
formControlName="typeFilter"
/>
<span> Mestre</span>
</label>
</li>
<li class="k-radio-item">
<label>
<input
type="radio"
kendoRadioButton
value="T"
formControlName="typeFilter"
/>
<span> Todos</span>
</label>
</li>
</ul>
</label>
</fieldset>
</form>
</div>
<div class="mt-3 row-buttons">
<button
kendoButton
data-bs-toggle="modal"
data-bs-target="#modalRange"
(click)="createPartnerRange()"
>
INCLUIR
</button>
<button
kendoButton
rounded="medium"
themeColor="waring"
(click)="searchRange()"
>
Pesquisar
</button>
</div>
</form>
</div>
<main class="flex-fill mt-3">
<div class="mt-3">
<kendo-grid
[kendoGridBinding]="gridView"
class="gridPartnerCategory"
(edit)="editPartnerRange($event)"
(remove)="confirmDelete($event)"
[sortable]="true"
[reorderable]="true"
[resizable]="true"
[columnMenu]="{ filter: true }"
>
<kendo-grid-column title="Código" field="id" width="80">
</kendo-grid-column>
<kendo-grid-column
title="Tipo Parceiro"
field="descriptionType"
width="100"
>
</kendo-grid-column>
<kendo-grid-column
field="rangeIni"
title="Faixa Inicial"
[width]="100"
filter="numeric"
>
<ng-template kendoGridCellTemplate let-dataItem>
<span [ngClass]="{ 'red text-bold': dataItem.rangeIni < 0 }">{{
dataItem.rangeIni | number : "1.2-2"
}}</span>
</ng-template>
</kendo-grid-column>
<kendo-grid-column
field="rangeFin"
title="Faixa Inicial"
[width]="100"
filter="numeric"
>
<ng-template
kendoGridCellTemplate
let-dataItem
style="text-align: right"
>
<span [ngClass]="{ 'red text-bold': dataItem.rangeFin < 0 }">{{
dataItem.rangeFin | number : "1.2-2"
}}</span>
</ng-template>
</kendo-grid-column>
<kendo-grid-column title="% Comissão" field="percentComiss" width="150">
</kendo-grid-column>
<kendo-grid-column title="Ações" [width]="60">
<ng-template kendoGridCellTemplate let-dataItem>
<div class="row g-2 justify-content-start">
<div class="col-3 me-2" kendoGridEditCommand>
<i
class="bi bi-pencil text-success"
data-bs-toggle="modal"
data-bs-target="#modalRange"
></i>
</div>
<div class="col-3 me-2" kendoGridRemoveCommand>
<i
class="bi bi-trash text-error"
></i>
</div>
</div>
</ng-template>
</kendo-grid-column>
<ng-template kendoGridNoRecordsTemplate>
<div>
<kendo-badge-container>
<kendo-icon name="user" size="large"></kendo-icon>
<kendo-badge position="inside" themeColor="error">
<kendo-icon name="close"></kendo-icon>
</kendo-badge>
</kendo-badge-container>
</div>
<p>
Não foram localizadas categorias com os filtros inforamdos,
verifique a pesquisa.
</p>
</ng-template>
</kendo-grid>
<!-- Modal -->
<!-- Vertically centered modal -->
<!-- Modal -->
<div
class="modal fade"
id="modalRange"
tabindex="-1"
aria-labelledby="modalRange"
aria-hidden="true"
>
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="modalRange">
Cadastro de faixa de comissão
</h5>
<button
type="button"
class="btn-close"
data-bs-dismiss="modal"
aria-label="Close"
></button>
</div>
<div class="modal-body">
<form class="k-form" [formGroup]="formRange">
<fieldset class="k-form-fieldset">
<label>
<span>Tipo do parceiro</span>
<ul class="k-radio-list k-list-horizontal">
<li class="k-radio-item">
<label>
<input
type="radio"
#mestre
value="B"
kendoRadioButton
formControlName="type"
/>
<span> Bella Obra</span>
</label>
</li>
<li class="k-radio-item">
<label>
<input
type="radio"
#mestre
value="P"
kendoRadioButton
formControlName="type"
/>
<span> Parceiro</span>
</label>
</li>
<li class="k-radio-item">
<label>
<input
type="radio"
#parceiro
kendoRadioButton
value="M"
formControlName="type"
/>
<span> Mestre</span>
</label>
</li>
</ul>
</label>
<div class="row mt-3">
<div class="col-6">
<label>
<span>Faixa Inicial</span>
<input
class="input-range"
formControlName="rangeIni"
type="number"
[min]="0"
[max]="90"
format="n2"
/>
</label>
</div>
<div class="col-6">
<label>
<span>Faixa Final</span>
<input
class="input-range"
formControlName="rangeFin"
type="number"
[min]="0"
[max]="90"
format="n2"
/>
</label>
</div>
</div>
<div class="mt-3">
<label>
<span> % Comissão </span>
<input
class="input-range"
formControlName="percentComiss"
type="number"
[min]="0"
[max]="90"
format="n2"
/>
</label>
</div>
</fieldset>
</form>
</div>
<div class="modal-footer">
<button
type="button"
class="btn btn-secondary"
data-bs-dismiss="modal"
>
Fechar
</button>
<button
type="button"
class="btn btn-primary"
data-bs-dismiss="modal"
(click)="savePartnerRange()"
>
Salvar
</button>
</div>
</div>
</div>
</div>
<!--div
class="modal fade modal-dialog-scrollable"
id="exampleModal"
tabindex="-1"
aria-labelledby="modalRange"
aria-hidden="true"
data-bs-backdrop="static" data-bs-keyboard="false"
-->
<!--div class="modal-dialog"-->
<!--div class="modal-dialog">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">
Cadastro de faixa de comissão
</h5>
<button
type="button"
class="btn-close"
data-bs-dismiss="modal"
aria-label="Close"
></button>
</div>
<div class="modal-body">
<form class="k-form" [formGroup]="formRange">
<fieldset class="k-form-fieldset">
<label>
<span>Tipo do parceiro</span>
<ul class="k-radio-list k-list-horizontal">
<li class="k-radio-item">
<label>
<input
type="radio"
#mestre
value="M"
kendoRadioButton
formControlName="type"
/>
<span> Parceiro</span>
</label>
</li>
<li class="k-radio-item">
<label>
<input
type="radio"
#parceiro
kendoRadioButton
value="P"
formControlName="type"
/>
<span> Mestre</span>
</label>
</li>
</ul>
</label>
<div class="row mt-3">
<div class="col-6">
<label>
<span>Faixa Inicial</span>
<input
class="input-range"
formControlName="rangeIni"
type="number"
[min]="0"
[max]="90"
format="n2"
/>
</label>
</div>
<div class="col-6">
<label>
<span>Faixa Final</span>
<input
class="input-range"
formControlName="rangeFin"
type="number"
[min]="0"
[max]="90"
format="n2"
/>
</label>
</div>
</div>
<div class="mt-3">
<label>
<span> % Comissão </span>
<input
class="input-range"
formControlName="percentComiss"
[min]="0"
[max]="90"
format="p"
/>
</label>
</div>
</fieldset>
</form>
</div>
<div class="modal-footer">
<button
type="button"
class="btn btn-secondary"
data-bs-dismiss="modal"
>
Fechar
</button>
<button
type="button"
class="btn btn-primary"
data-bs-dismiss="modal"
(click)="savePartnerRange()"
>
Salvar
</button>
</div>
</!--div>
</div>
</div-->
</div>
</main>
</div>
<kendo-dialog
title="Exclusão de faixa de comissão"
*ngIf="opened"
(close)="resultDelete('cancel')"
[minWidth]="250"
[width]="450"
>
<p style="margin: 30px; text-align: center;">
Confirma exclusão da faixa?
</p>
<kendo-dialog-actions>
<button kendoButton (click)="resultDelete('no')">Não</button>
<button kendoButton (click)="resultDelete('yes')" themeColor="primary">
Sim
</button>
</kendo-dialog-actions>
</kendo-dialog>

View File

@@ -0,0 +1,37 @@
.wrapper {
min-height: calc(100vh - 80px);
}
.gridPartnerCatetgory {
max-height: calc(100vh - 410px);
}
.form-partner {
display: flex;
justify-content: start;
}
.wrap {
display: flex;
justify-content: space-between;
}
.wrap .arrival-date {
width: 90%;
margin-right: 18px;
}
.k-form {
width: 100%;
background-color: white;
padding: 25px;
}
label {
width: 100%;
}
.row-buttons {
display: flex;
justify-content: start space-between;
}
.row-buttons button {
margin-right: 10px;
}

View File

@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { PartnerRangeComponent } from './partner-range.component';
describe('PartnerRangeComponent', () => {
let component: PartnerRangeComponent;
let fixture: ComponentFixture<PartnerRangeComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ PartnerRangeComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(PartnerRangeComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -0,0 +1,141 @@
import { Component, OnInit, ViewChild } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { Observable, of } from 'rxjs';
import { PartnerRange } from 'src/app/models/partner-range.model';
import { PartnerRangeService } from 'src/app/services/partner-range.service';
import { FormControl, FormGroup, Validators } from '@angular/forms';
import { AuthService } from 'src/app/auth/services/auth.service';
import { User } from 'src/app/models/user.model';
import { catchError, tap } from 'rxjs/operators';
import { DataBindingDirective } from '@progress/kendo-angular-grid';
@Component({
selector: 'app-partner-range',
templateUrl: './partner-range.component.html',
styleUrls: ['./partner-range.component.scss']
})
export class PartnerRangeComponent implements OnInit {
@ViewChild(DataBindingDirective) dataBinding: DataBindingDirective;
public gridView: unknown[];
partnerRange$: Observable<PartnerRange[]>;
formRange: FormGroup;
rangeIni = 0;
rangeFin = 0;
percent = 0;
partnerRangeSelect: PartnerRange = null;
loading = false;
formFilter: FormGroup;
public opened = false;
selectedPartnerRange: PartnerRange;
public resultDelete(status: string): void {
console.log(`Dialog result: ${status}`);
this.opened = false;
if (status == 'yes') {
this.deleteRange();
}
}
constructor(
private readonly partnerRangeService: PartnerRangeService,
private route: ActivatedRoute,
private router: Router,
private authService: AuthService
) {
}
ngOnInit(): void {
this.formFilter = new FormGroup({
typeFilter: new FormControl('T', []),
});
this.partnerRangeService.getPartnerRange('T').subscribe(range => {
this.gridView = range;
});
this.formRange = new FormGroup({
id: new FormControl(),
rangeIni: new FormControl(this.rangeIni, [Validators.required]),
rangeFin: new FormControl(this.rangeFin, [Validators.required]),
percentComiss: new FormControl(this.percent, [Validators.required]),
type: new FormControl(),
});
}
editPartnerRange(data) {
console.log(data);
this.partnerRangeSelect = data.dataItem as PartnerRange;
this.formRange.patchValue({
id: this.partnerRangeSelect.id,
rangeIni: this.partnerRangeSelect.rangeIni,
rangeFin: this.partnerRangeSelect.rangeFin,
percentComiss: this.partnerRangeSelect.percentComiss,
type: this.partnerRangeSelect.type,
});
// this.router.navigate([`/partner/range/edit/range/${data.dataItem.id}`]);
}
confirmDelete(data: any) {
console.log(data);
this.selectedPartnerRange = data.dataItem as PartnerRange;
this.opened = true;
}
createPartnerRange() {
this.partnerRangeSelect = null;
this.formRange.reset();
}
savePartnerRange() {
console.log(this.formRange.value);
const user = this.authService.getUser();
console.log(this.formRange.get('rangeIni').value);
if ( this.partnerRangeSelect == null ){
this.partnerRangeSelect = new PartnerRange();
}
this.partnerRangeSelect.rangeIni = this.formRange.get('rangeIni').value;
this.partnerRangeSelect.rangeFin = this.formRange.get('rangeFin').value;
this.partnerRangeSelect.percentComiss = this.formRange.get('percentComiss').value;
this.partnerRangeSelect.type = this.formRange.get('type').value;
this.partnerRangeSelect.createUserId = user.id;
this.partnerRangeSelect.updateUserId = user.id;
this.loading = true;
this.partnerRangeService.createOrReplace(this.partnerRangeSelect).pipe(
tap(() => {
this.searchRange();
this.loading = false;
}),
catchError((error) => {
console.log(error);
return of(error.message);
})
).subscribe();
}
searchRange() {
const type = this.formFilter.get('typeFilter').value;
this.partnerRangeService.getPartnerRange(type).subscribe(range => {
this.gridView = range;
});
}
deleteRange() {
this.loading = true;
this.partnerRangeService.DeletePartnerRangeById(this.selectedPartnerRange.id.toString())
.pipe(
tap(() => {
this.searchRange();
this.loading = false;
}),
catchError((error) => {
console.log(error);
return of(error.message);
})
).subscribe();
}
}

View File

@@ -0,0 +1,181 @@
<div class="d-flex flex-column wrapper">
<div class="row">
<div class="col-12">
<form class="k-form shadow bg-body rounded" [formGroup]="formFilter">
<h4>RELATÓRIO DE COMISSÃO DE PARCEIROS</h4>
<!-- <label>
<span>CPF</span>
<kendo-textbox
formControlName="cpf"
placeholder="Informe o CPF do parceiro"
></kendo-textbox>
</label>
<label class="mt-2">
<span>Nome</span>
<kendo-textbox
formControlName="name"
placeholder="Informe o nome do parceiro"
></kendo-textbox>
</label> -->
<label>
<span>Parceiro</span>
<kendo-combobox
#partner
formControlName="partner"
[data]="partners$ | async"
textField="name"
valueField="id"
[kendoDropDownFilter]="{ operator: 'contains' }"
(selectionChange)="selectPartner($event)"
></kendo-combobox>
</label>
<kendo-daterange #daterange>
<div class="row">
<div class="col-12 col-sm-12 col-md-6 col-lg-3">
<kendo-floatinglabel text="Inicio">
<kendo-dateinput
kendoDateRangeStartInput
[(value)]="range.start"
></kendo-dateinput>
</kendo-floatinglabel>
</div>
<div class="col-12 col-sm-12 col-md-6 col-lg-3">
<kendo-floatinglabel text="Fim">
<kendo-dateinput
kendoDateRangeEndInput
[(value)]="range.end"
></kendo-dateinput>
</kendo-floatinglabel>
</div>
</div>
</kendo-daterange>
<div class="col-12 col-sm-8 col-md-8 col-lg-8">
<div class="row mt-3">
<div class="col-12">
<span>Tipo de parceiro</span>
</div>
<div class="col-sm-12 col-md-3 col-lg-3">
<label>
<input
type="radio"
name="type"
value="B"
#other
formControlName="type"
kendoRadioButton
/>
<span class="in-line ms-2">Bella Obra</span>
</label>
</div>
<div class="col-sm-12 col-md-3 col-lg-3">
<label>
<input
type="radio"
name="type"
value="P"
#other
formControlName="type"
kendoRadioButton
/>
<span class="in-line ms-2">Parceiros</span>
</label>
</div>
<div class="col-sm-12 col-md-3 col-lg-3">
<label>
<input
type="radio"
name="type"
value="M"
#other
formControlName="type"
kendoRadioButton
/>
<span class="in-line ms-2">Mestre Jurunense</span>
</label>
</div>
<div class="col-sm-12 col-md-3 col-lg-3">
<label>
<input
type="radio"
name="type"
value="T"
#other
formControlName="type"
kendoRadioButton
/>
<span class="in-line ms-2">Todos</span>
</label>
</div>
</div>
</div>
<!-- <div class="row mt-2">
<div class="col-12">
<span>Tipo de parceiro</span>
</div>
<div class="col-sm-12 col-md-4 col-lg-2">
<label>
<input
type="radio"
name="type"
value="P"
#other
formControlName="type"
kendoRadioButton
/>
<span class="in-line">Parceiros</span>
</label>
</div>
<div class="col-sm-12 col-md-4 col-lg-3">
<label>
<input
type="radio"
name="type"
value="M"
#other
formControlName="type"
kendoRadioButton
/>
<span class="in-line">Mestre Jurunense</span>
</label>
</div>
<div class="col-sm-12 col-md-4 col-lg-2">
<label>
<input
type="radio"
name="type"
value="T"
#other
formControlName="type"
kendoRadioButton
/>
<span class="in-line">Todos</span>
</label>
</div>
</div> -->
<div class="mt-3 row-buttons">
<button kendoButton rounded="medium" themeColor="primary" (click)="openClose(true)">
Pesquisar
</button>
</div>
</form>
</div>
</div>
</div>
<kendo-window
[top]="100"
[left]="50"
title="RELATÓRIO DE COMISSÃO DE PARCEIROS"
[(state)]="windowState"
*ngIf="opened"
(close)="openClose(false)"
>
<stimulsoft-viewer-angular
[requestUrl]="urlPrintPreOrder"
[action]="'InitViewerComissaoParceiro'"
[width]="'95%'"
[height]="'800px'"
></stimulsoft-viewer-angular>
</kendo-window>

View File

@@ -0,0 +1,38 @@
.form-partner {
display: flex;
justify-content: start;
}
.gridPartners {
max-height: calc(100vh - 410px);
}
.wrap {
display: flex;
justify-content: space-between;
}
.wrap .arrival-date {
width: 90%;
margin-right: 18px;
}
.k-form {
background-color: white;
padding: 25px;
}
label {
width: 100%;
}
input[type="radio"] {
margin-right: 16px;
vertical-align: text-bottom;
}
.row-buttons {
display: flex;
justify-content: start space-between;
}
.row-buttons button {
margin-right: 10px;
}

View File

@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { CommissionComponent } from './commission.component';
describe('CommissionComponent', () => {
let component: CommissionComponent;
let fixture: ComponentFixture<CommissionComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ CommissionComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(CommissionComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -0,0 +1,88 @@
import { Component, OnInit, ViewChild } from '@angular/core';
import { FormControl, FormGroup } from '@angular/forms';
import { DateRangeService } from '@progress/kendo-angular-dateinputs';
import { WindowState } from '@progress/kendo-angular-dialog';
import { Observable } from 'rxjs';
import { PartnerSales } from 'src/app/models/partners-sales.model';
import { Partners } from 'src/app/models/partners.model';
import { LookupService } from 'src/app/services/lookup.service';
import { PartnerService } from 'src/app/services/partner.service';
@Component({
selector: 'app-commission',
templateUrl: './commission.component.html',
styleUrls: ['./commission.component.scss']
})
export class CommissionComponent implements OnInit {
formFilter: FormGroup;
partners$: Observable<Partners[]>;
selectedPartner: Partners;
@ViewChild('daterange', { read: DateRangeService })
public service: DateRangeService;
public range = { start: new Date(), end: new Date() };
public windowState: WindowState = 'maximized';
public opened = false;
public urlPrintPreOrder = '';
constructor(
private readonly lookupService: LookupService,
private readonly partnerService: PartnerService,
) {
this.formFilter = new FormGroup({
cpf: new FormControl(null),
name: new FormControl(null),
partner: new FormControl(null),
type: new FormControl('T'),
});
}
ngOnInit(): void {
this.partners$ = this.partnerService.getPartnerByQuery('T', null, null);
}
public openClose(isOpened: boolean): void {
if (isOpened) {
let partnerId = -1;
if (this.selectedPartner !== null && this.selectedPartner !== undefined) {
partnerId = this.selectedPartner.id;
}
let intType = 99;
const type = this.formFilter.get('type').value;
switch (type) {
case 'P':
intType = 1;
break;
case 'M':
intType = 2;
break;
case 'B':
intType = 3;
break;
default:
intType = 99;
break;
}
console.log("tipo: " + intType);
this.urlPrintPreOrder =
`http://10.1.1.205:8068/Viewer/{action}?partnerId=${partnerId}&type=${type}&start=${this.range.start.toUTCString()}&end=${this.range.end.toUTCString()}`;
// `http://localhost:52986/Viewer/{action}?partnerId=${this.selectedPartner.id}
// &start=${this.range.start.toUTCString()}&end=${this.range.end.toUTCString()}`;
}
this.opened = isOpened;
}
public selectPartner(partner: any) {
console.log(partner);
this.selectedPartner = null;
if (partner) {
this.selectedPartner = partner;
}
}
}

View File

@@ -0,0 +1,40 @@
.nav-extract {
background-color: #131d52;
height: 60px;
}
.logo {
color: white;
font-weight: 900ng;
}
@media (max-width: 450px)
{
.menu
{
display: flex;
}
}
@media (min-width: 451px)
{
.menu
{
display: none;
}
}
.loading-container {
height: 100%;
display: flex;
justify-content: center;
align-items: center;
}
.nav-user {
background-color: #131d52;
}
.k-i-user {
color: white;
}

View File

@@ -0,0 +1,441 @@
<div class="container d-flex flex-column h-100 p-0">
<div class="row mx-1">
<div class="col-sm-12 p-2">
<div class="k-form shadow bg-body rounded p-3">
<h4>EXTRATO DA MOVIMENTAÇÃO DOS PARCEIROS</h4>
<label class="w-100">
<span>Parceiro</span>
<kendo-combobox
#partner
[data]="partners$ | async"
textField="name"
valueField="id"
[kendoDropDownFilter]="{ operator: 'contains' }"
(selectionChange)="selectPartner($event)"
></kendo-combobox>
</label>
<kendo-daterange #daterange>
<div class="row">
<div class="col-12 col-sm-12 col-md-6 col-lg-3">
<kendo-floatinglabel text="Inicio">
<kendo-dateinput
kendoDateRangeStartInput
[(value)]="range.start"
></kendo-dateinput>
</kendo-floatinglabel>
</div>
<div class="col-12 col-sm-12 col-md-6 col-lg-3">
<kendo-floatinglabel text="Fim">
<kendo-dateinput
kendoDateRangeEndInput
[(value)]="range.end"
></kendo-dateinput>
</kendo-floatinglabel>
</div>
</div>
</kendo-daterange>
<div class="mt-3 row-buttons">
<button
kendoButton
rounded="medium"
themeColor="primary"
(click)="getComission()"
>
Pesquisar
</button>
</div>
</div>
</div>
<!-- <div class="col-sm-12">
<kendo-daterange>
<kendo-floatinglabel text="Início" style="width: 120px">
<kendo-dateinput
kendoDateRangeStartInput
[(value)]="range.start"
></kendo-dateinput>
</kendo-floatinglabel>
<kendo-floatinglabel class="ms-2" text="Término" style="width: 120px">
<kendo-dateinput
#endDateInput
kendoDateRangeEndInput
[(value)]="range.end"
></kendo-dateinput>
</kendo-floatinglabel>
<kendo-daterange-popup>
<ng-template kendoDateRangePopupTemplate>
<kendo-multiviewcalendar kendoDateRangeSelection>
</kendo-multiviewcalendar>
</ng-template>
</kendo-daterange-popup>
</kendo-daterange>
</div>
<div class="col-sm-12 mt-2">
<button kendoButton (click)="getComission()">Pesquisar</button>
</div> -->
</div>
<div class="flex-fill mt-3">
<kendo-grid
[data]="gridData"
[resizable]="true"
[scrollable]="true"
[loading]="loading"
style="height: 100hv; width: 100wv"
>
<ng-template kendoGridNoRecordsTemplate>
<h4>Sem registros para serem exibidos.</h4>
<p>Verifique o período informado e pesquise novamente.</p>
</ng-template>
<ng-template class="mt-4" kendoGridLoadingTemplate>
<div class="k-loading-color"></div>
<div class="loading-container">
<kendo-loader type="converging-spinner" size="large"></kendo-loader>
</div>
</ng-template>
<kendo-grid-column media="(max-width: 450px)" title="Movimentação">
<ng-template kendoGridCellTemplate let-dataItem>
<!-- template for mobile -->
<div
*ngIf="
dataItem.type != 'DEPOSITO' &&
dataItem.type != 'SALDO MES' &&
dataItem.type != 'SALDO INICIAL'
"
>
<dl>
<div class="row">
<div class="col-3">
<dt>Tipo</dt>
<dd>
<span
*ngIf="dataItem.type == 'VENDA'"
class="badge bg-primary"
>{{ dataItem.type }}</span
>
<span
*ngIf="dataItem.type == 'DEVOLUCAO'"
class="badge bg-danger"
>{{ dataItem.type }}</span
>
<span
*ngIf="dataItem.type == 'DEPOSITO'"
class="badge bg-warning"
>{{ dataItem.type }}</span
>
<span
*ngIf="dataItem.type == 'CREDITO'"
class="badge bg-warning"
>{{ dataItem.type }}</span
>
</dd>
</div>
<div class="col-3">
<dt>Loja</dt>
<dd>{{ dataItem.store }}</dd>
</div>
<div class="col-6">
<dt>Cliente</dt>
<dd>
<small> {{ dataItem.customer }}</small>
</dd>
</div>
</div>
<div class="row">
<div class="col-3">
<dt>Nota</dt>
<dd>{{ dataItem.number }}</dd>
</div>
<div class="col-3">
<dt>Data</dt>
<dd>{{ dataItem.dateSale | date:'dd/MM/yyyy':'UTC' }}</dd>
</div>
<div class="col-6">
<dt>Vendedor</dt>
<dd>
<small> {{ dataItem.seller }}</small>
</dd>
</div>
</div>
<div class="row">
<div class="col-4">
<dt>Valor</dt>
<dd>{{ dataItem.valueSale | currency }}</dd>
</div>
<div class="col-4">
<dt>Comissão</dt>
<dd>{{ dataItem.valueCommission | currency }}</dd>
</div>
<div class="col-4">
<dt>Saldo</dt>
<dd>{{ dataItem.balance | currency }}</dd>
</div>
</div>
</dl>
</div>
<div *ngIf="dataItem.type == 'DEPOSITO'">
<dl>
<div class="row">
<div class="col-3">
<dt>Tipo</dt>
<dd>
<span
*ngIf="dataItem.type == 'VENDA'"
class="badge bg-primary"
>{{ dataItem.type }}</span
>
<span
*ngIf="dataItem.type == 'DEVOLUCAO'"
class="badge bg-danger"
>{{ dataItem.type }}</span
>
<span
*ngIf="dataItem.type == 'DEPOSITO'"
class="badge bg-warning"
>{{ dataItem.type }}</span
>
<span
*ngIf="dataItem.type == 'CREDITO'"
class="badge bg-warning"
>{{ dataItem.type }}</span
>
</dd>
</div>
<div class="col-3">
<dt>Loja</dt>
<dd>{{ dataItem.store }}</dd>
</div>
<div class="col-6">
<dt>Forma de pagamento</dt>
<dd>
<span class="badge bg-warning">{{
dataItem.paidType
}}</span>
</dd>
</div>
</div>
<div class="row">
<div class="col-3">
<dt>data</dt>
<dd>{{ dataItem.dateSale | date:'dd/MM/yyyy':'UTC' }}</dd>
</div>
<div class="col-3">
<dt>Pagto</dt>
<dd>{{ dataItem.datePaid | date:'dd/MM/yyyy':'UTC' }}</dd>
</div>
<div class="col-3">
<dt>Valor</dt>
<dd>{{ dataItem.valueCreate | currency }}</dd>
</div>
<div class="col-3">
<dt>Saldo</dt>
<dd>{{ dataItem.balance | currency }}</dd>
</div>
</div>
</dl>
</div>
<div *ngIf="dataItem.type == 'SALDO INICIAL'">
<dl>
<div class="row">
<div class="col-4">
<dt>Tipo</dt>
<dd>
<span
*ngIf="dataItem.type == 'SALDO INICIAL'"
class="badge bg-success"
>{{ dataItem.type }}</span
>
</dd>
</div>
<div class="col-4">
<dt>Data</dt>
<dd>{{ dataItem.dateSale | date:'dd/MM/yyyy':'UTC' }}</dd>
</div>
<div class="col-4">
<dt>Saldo</dt>
<dd>{{ dataItem.balance | currency }}</dd>
</div>
</div>
</dl>
</div>
<div *ngIf="dataItem.type == 'SALDO MES'">
<dl>
<div class="row">
<div class="col-3">
<dt>Tipo</dt>
<dd>
<span class="badge bg-secondary">{{ dataItem.type }}</span>
</dd>
</div>
<div class="col-3">
<dt>Data</dt>
<dd>{{ dataItem.dateSale | date:'dd/MM/yyyy':'UTC' }}</dd>
</div>
<div class="col-3">
<dt>Saldo</dt>
<dd>{{ dataItem.valueCommission | currency }}</dd>
</div>
<div class="col-3">
<dt>Saldo</dt>
<dd>{{ dataItem.balance | currency }}</dd>
</div>
</div>
</dl>
</div>
</ng-template>
</kendo-grid-column>
<!-- columns for mid-size devices -->
<kendo-grid-column
media="(min-width: 450px)"
field="store"
title="Loja"
[width]="50"
>
</kendo-grid-column>
<kendo-grid-column
media="(min-width: 450px)"
field="type"
title="Tipo"
[width]="100"
>
<ng-template kendoGridCellTemplate let-dataItem>
<span
*ngIf="dataItem.type == 'SALDO INICIAL'"
class="badge bg-success"
>{{ dataItem.type }}</span
>
<span
*ngIf="dataItem.type == 'SALDO MES'"
class="badge bg-secondary"
>{{ dataItem.type }}</span
>
<span *ngIf="dataItem.type == 'VENDA'" class="badge bg-primary">{{
dataItem.type
}}</span>
<span *ngIf="dataItem.type == 'DEVOLUCAO'" class="badge bg-danger">{{
dataItem.type
}}</span>
<span *ngIf="dataItem.type == 'DEPOSITO'" class="badge bg-warning">{{
dataItem.type
}}</span>
<span *ngIf="dataItem.type == 'CREDITO'" class="badge bg-warning">{{
dataItem.type
}}</span>
</ng-template>
</kendo-grid-column>
<kendo-grid-column
media="(min-width: 450px)"
field="dateSale"
title="Data venda"
[width]="100"
>
<ng-template kendoGridCellTemplate let-dataItem>
{{ dataItem.dateSale | date:'dd/MM/yyyy':'UTC' }}
</ng-template>
</kendo-grid-column>
<!-- additional columns on large devices -->
<kendo-grid-column
media="(min-width: 680px)"
field="number"
title="Número NF"
[width]="90"
>
</kendo-grid-column>
<kendo-grid-column
media="(min-width: 680px)"
field="seller"
title="Vendedor"
[width]="130"
>
</kendo-grid-column>
<kendo-grid-column
media="(min-width: 680px)"
field="customer"
title="Cliente"
[width]="180"
>
</kendo-grid-column>
<kendo-grid-column
media="(min-width: 680px)"
field="valueSale"
title="Valor venda"
[width]="110"
[class]="{ 'text-end': true }"
>
<ng-template kendoGridCellTemplate let-dataItem>
{{ dataItem.valueSale | currency }}
</ng-template>
</kendo-grid-column>
<kendo-grid-column
media="(min-width: 680px)"
field="pecentCommission"
title="%Comis"
[width]="80"
[class]="{ 'text-end': true }"
>
<ng-template kendoGridCellTemplate let-dataItem>
{{ dataItem.pecentCommission | number : "1.2-2" }}
</ng-template>
</kendo-grid-column>
<kendo-grid-column
media="(min-width: 680px)"
field="valueCommission"
title="Vl Comissão"
[width]="100"
[class]="{ 'text-end': true }"
>
<ng-template kendoGridCellTemplate let-dataItem>
{{ dataItem.valueCommission | currency }}
</ng-template>
</kendo-grid-column>
<kendo-grid-column
media="(min-width: 680px)"
field="valueCreate"
title="Vl Gerado"
[width]="100"
[class]="{ 'text-end': true }"
>
<ng-template kendoGridCellTemplate let-dataItem>
{{ dataItem.valueCreate | currency }}
</ng-template>
</kendo-grid-column>
<kendo-grid-column
media="(min-width: 680px)"
field="datePaid"
title="Data Pagto"
[width]="100"
>
<ng-template kendoGridCellTemplate let-dataItem>
{{ dataItem.datePaid | date:'dd/MM/yyyy':'UTC' }}
</ng-template>
</kendo-grid-column>
<kendo-grid-column
media="(min-width: 680px)"
field="balance"
title="Saldo"
[width]="100"
[class]="{ 'text-end': true }"
>
<ng-template kendoGridCellTemplate let-dataItem>
{{ dataItem.balance | currency }}
</ng-template>
</kendo-grid-column>
</kendo-grid>
</div>
</div>

View File

@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';
import { ExtractPartnerComponent } from './extract-partner.component';
describe('ExtractPartnerComponent', () => {
let component: ExtractPartnerComponent;
let fixture: ComponentFixture<ExtractPartnerComponent>;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ ExtractPartnerComponent ]
})
.compileComponents();
}));
beforeEach(() => {
fixture = TestBed.createComponent(ExtractPartnerComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});
it('should create', () => {
expect(component).toBeTruthy();
});
});

View File

@@ -0,0 +1,78 @@
import { Component, OnInit, ViewChild } from '@angular/core';
import { DateRangeService, SelectionRange } from '@progress/kendo-angular-dateinputs';
import { Observable, of } from 'rxjs';
import { catchError, map } from 'rxjs/operators';
import { arrowRightIcon, paperclipIcon } from '@progress/kendo-svg-icons';
import { ExtractPartner } from 'src/app/models/extract-partner.model';
import { PartnerService } from 'src/app/services/partner.service';
import { Partners } from 'src/app/models/partners.model';
import { FormGroup } from '@angular/forms';
@Component({
selector: 'app-extract-partner',
templateUrl: './extract-partner.component.html',
styleUrls: ['./extract-partner.component.css']
})
export class ExtractPartnerComponent implements OnInit {
public range: SelectionRange = { start: null, end: null };
constructor (
private readonly partnerService: PartnerService) {}
extractPartner$: Observable<ExtractPartner[]>;
public gridData: ExtractPartner[] = [];
public loading: boolean = false;
public icons = { arrowRight: arrowRightIcon };
formFilter: FormGroup;
partners$: Observable<Partners[]>;
selectedPartner: Partners;
@ViewChild('daterange', { read: DateRangeService })
public service: DateRangeService;
//dados do parceiro
partnerId: number = 0;
partnerName: string = '';
partnerType: string = '';
ngOnInit(): void {
this.partners$ = this.partnerService.getPartnerByQuery('T', null, null);
if (localStorage.getItem('user-partner') != null ) {
const dataPartner = JSON.parse(localStorage.getItem('user-partner'));
this.partnerId = dataPartner.id;
this.partnerName = dataPartner.username + ' (Código: ' + dataPartner.id + ')';
this.partnerType = dataPartner.type;
}
}
getComission() {
if ( this.selectedPartner == null ) {
return;
}
this.loading = true;
const partnerId = this.selectedPartner.id;
this.partnerService.getExtractPartner(partnerId, this.range.start, this.range.end)
.pipe(
map(response => {
this.gridData = response;
console.log(response);
this.loading = false;
}),
catchError(err => {
this.loading = false;
console.log(err);
return of();
})
).subscribe();
}
public selectPartner(partner: any) {
this.selectedPartner = null;
if (partner) {
this.selectedPartner = partner;
}
}
}