Skip to content

Commit

Permalink
Merge pull request #27 from leoriofrio/Dev
Browse files Browse the repository at this point in the history
feat: kit, new check validation
  • Loading branch information
leoriofrio authored Nov 7, 2020
2 parents 60d4b8b + e728c63 commit 0252569
Show file tree
Hide file tree
Showing 30 changed files with 950 additions and 57 deletions.
2 changes: 2 additions & 0 deletions src/app/admin/menu/menu.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ <h2 class="brand-text mb-0">Santillana</h2>
</li>
<li class=" nav-item"><a routerLink="/product"><i class="bx bx-grid-alt"></i><span class="menu-title" data-i18n="Kanban">Productos</span></a>
</li>
<li class=" nav-item"><a routerLink="/kit"><i class="bx bx-grid-alt"></i><span class="menu-title" data-i18n="Kanban">Kit de Productos</span></a>
</li>
<li class=" nav-item"><a routerLink="/client"><i class="bx bx-grid-alt"></i><span class="menu-title" data-i18n="Kanban">Clientes</span></a>
</li>
<li class=" nav-item"><a routerLink="/college"><i class="bx bx-grid-alt"></i><span class="menu-title" data-i18n="Kanban">Colegios</span></a>
Expand Down
24 changes: 13 additions & 11 deletions src/app/app.keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,22 @@ export namespace ProformDetail {
export const ID = {prop: 'id', name: 'Id'};
export const PROFORM_ID = {prop: 'proform_id', name: 'proform_id'};
export const DEGREE = {prop: 'degree', name: 'Grado'};
export const PRODUCT_ID = {prop: 'product_id', name: 'product_Id'};
export const PRODUCT_ID = {prop: 'product_id', name: 'Producto'};
export const QUANTITY = {prop: 'quantity', name: 'Cantidad'};
export const PRICE = {prop: 'price', name: 'Precio'};
export const SUB_TOTAL = {prop: 'subtotal', name: 'Subtotal'};
export const SALE_DIRECT = {prop: 'sale_direct', name: 'DIRECTO'};
export const SALE_EXTERNAL_LIBRARY = {prop: 'sale_external_library', name: 'LIBRERÍA EXTERNA'};
export const SALE_EVENT = {prop: 'sale_event', name: 'Material Promocional Premios para eventos'};
export const SALE_TEACHER = {prop: 'sale_teacher', name: 'Material Promocional para profesores'};
export const SALE_INFRASTRUCTURE = {prop: 'sale_infrastructure', name: 'Infraestructura PLANTEL'};
export const SALE_SCHOLARSHIPS = {prop: 'sale_scholarships', name: 'Becas PLANTEL'};
export const SALE_STAFF = {prop: 'sale_staff', name: 'Equipos PLANTEL'};
export const SALE_TRAINING = {prop: 'sale_training', name: 'Capacitación PLANTEL'};
export const CAPEX = {prop: 'capex', name: 'Beneficio'};
export const SALE_DIRECT = {prop: 'sale_direct', name: 'Directo'};
export const SALE_DONATION = {prop: 'sale_donation', name: 'Donación'};
export const SALE_EXTERNAL_LIBRARY = {prop: 'sale_external_library', name: 'Librería'};
export const SALE_EVENT = {prop: 'sale_event', name: 'Premios'};
export const SALE_TEACHER = {prop: 'sale_teacher', name: 'Profesores'};
export const SALE_INFRASTRUCTURE = {prop: 'sale_infrastructure', name: 'Infraestructura'};
export const SALE_SCHOLARSHIPS = {prop: 'sale_scholarships', name: 'Becas'};
export const SALE_STAFF = {prop: 'sale_staff', name: 'Equipos'};
export const SALE_TRAINING = {prop: 'sale_training', name: 'Capacitación'};
export const CAPEX = {prop: 'capex', name: 'Capex'};
export const TOTAL = {prop: 'total', name: 'Total'};
export const QUANTITY_CHECK = {prop: 'quantity_check', name: 'Entregado'};
}

export namespace TypeClientSale {
Expand All @@ -104,7 +106,7 @@ export namespace ProductColumns {
export const NIVEL = {prop: 'nivel', name: 'Nivel Educación'};
export const DEGREE = {prop: 'degree', name: 'Grado'};
export const BUSINESS_LINE = {prop: 'businessLine', name: 'Linea Negocios'};
export const ISBN = {prop: 'isbn', name: 'ISBN'};
export const ISBN = {prop: 'isbn', name: 'EAN'};
export const REGION = {prop: 'region', name: 'Región'};

}
Expand Down
2 changes: 1 addition & 1 deletion src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { PriceComponent } from './configuration/price/price.component';
declarations: [
AppComponent,
UploadDirective,
PriceComponent
PriceComponent,
],
imports: [
BrowserModule,
Expand Down
10 changes: 8 additions & 2 deletions src/app/app.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export type GridRecord = {
quantity: 0,
price: 0,
sale_direct: 0,
sale_donation: 0,
sale_external_library: 0,
sale_event: 0,
sale_teacher: 0,
Expand All @@ -67,6 +68,7 @@ export type GridRecord = {
quantity: 0,
subtotal:0,
sale_direct: number,
sale_donation: number,
sale_external_library: number,
sale_event: number,
sale_teacher: number,
Expand All @@ -88,14 +90,16 @@ export type GridRecord = {
"subtotal":0,
"total":0,
"sale_direct": 0,
"sale_donation": 0,
"sale_external_library": 0,
"sale_event": 0,
"sale_teacher": 0,
"sale_infrastructure": 0,
"sale_scholarships": 0,
"sale_staff": 0,
"sale_training": 0,
"capex": 0
"capex": 0,
"quantity_check": 0,
};


Expand All @@ -105,6 +109,7 @@ export type GridRecord = {
"quantity": 0,
"price": 0,
"sale_direct": 0,
"sale_donation": 0,
"sale_external_library": 0,
"sale_event": 0,
"sale_teacher": 0,
Expand All @@ -114,7 +119,8 @@ export type GridRecord = {
"sale_training": 0,
"capex": 0,
"proform_id": 0,
"product_id": 0
"product_id": 0,
"quantity_check": 0,
};


Expand Down
2 changes: 2 additions & 0 deletions src/app/configuration/configuration-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import { UserComponent } from './user/user.component';
import { CollegesComponent } from './colleges/colleges.component';
import { CampaignComponent } from './campaign/campaign.component';
import { PriceComponent } from './price/price.component';
import { KitComponent } from './kit/kit.component';

const configurationRoutes: Routes = [
{ path: 'kit', component: KitComponent },
{ path: 'product', component: ProductComponent },
{ path: 'client', component: ClientComponent },
{ path: 'user', component: UserComponent},
Expand Down
4 changes: 3 additions & 1 deletion src/app/configuration/configuration.modules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { ClientComponent } from './client/client.component';
import { UserComponent } from './user/user.component';
import { CollegesComponent } from './colleges/colleges.component';
import { CampaignComponent } from './campaign/campaign.component';
import { KitComponent } from './kit/kit.component';

@NgModule({
imports: [
Expand All @@ -27,7 +28,8 @@ import { CampaignComponent } from './campaign/campaign.component';
ClientComponent,
UserComponent,
CollegesComponent,
CampaignComponent
CampaignComponent,
KitComponent
],
providers: [],
exports: [],
Expand Down
Empty file.
15 changes: 15 additions & 0 deletions src/app/configuration/kit/kit.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

<content >

<!-- BEGIN: Content-->
<div class="app-content content">
<div class="content-overlay"></div>
<div class="content-wrapper">
<div class="content-header row">Kit de Productos
</div>

</div>
</div>
<!-- END: Content-->

</content>
25 changes: 25 additions & 0 deletions src/app/configuration/kit/kit.component.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { async, ComponentFixture, TestBed } from '@angular/core/testing';

import { KitComponent } from './kit.component';

describe('KitComponent', () => {
let component: KitComponent;
let fixture: ComponentFixture<KitComponent>;

beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ KitComponent ]
})
.compileComponents();
}));

beforeEach(() => {
fixture = TestBed.createComponent(KitComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
15 changes: 15 additions & 0 deletions src/app/configuration/kit/kit.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Component, OnInit } from '@angular/core';

@Component({
selector: 'app-kit',
templateUrl: './kit.component.html',
styleUrls: ['./kit.component.css']
})
export class KitComponent implements OnInit {

constructor() { }

ngOnInit(): void {
}

}
42 changes: 23 additions & 19 deletions src/app/shared/components/grid/grid.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ export class GridComponent implements OnInit, OnDestroy {
case 'price':
case 'subtotal':
case 'sale_direct':
case 'sale_donation':
case 'sale_external_library':
case 'sale_event':
case 'sale_teacher':
Expand All @@ -134,21 +135,23 @@ export class GridComponent implements OnInit, OnDestroy {
varField = _.replace(row[3], '%', '');
varField = _.replace(varField, ',', '.');
varRow = (row[1] === 'sale_direct' && varRow === 0 ) ? varRow = 7 : varRow = varRow;
varRow = (row[1] === 'sale_external_library' && varRow === 0 ) ? varRow = 8 : varRow = varRow;
varRow = (row[1] === 'sale_event' && varRow === 0 ) ? varRow = 9 : varRow = varRow;
varRow = (row[1] === 'sale_teacher' && varRow === 0 ) ? varRow = 10 : varRow = varRow;
varRow = (row[1] === 'sale_infrastructure' && varRow === 0 ) ? varRow = 11 : varRow = varRow;
varRow = (row[1] === 'sale_scholarships' && varRow === 0 ) ? varRow = 12 : varRow = varRow;
varRow = (row[1] === 'sale_staff' && varRow === 0 ) ? varRow = 13 : varRow = varRow;
varRow = (row[1] === 'sale_training' && varRow === 0 ) ? varRow = 14 : varRow = varRow;
varRow = (row[1] === 'capex' && varRow === 0 ) ? varRow = 15 : varRow = varRow;
varRow = (row[1] === 'sale_donation' && varRow === 0 ) ? varRow = 8 : varRow = varRow;
varRow = (row[1] === 'sale_external_library' && varRow === 0 ) ? varRow = 9 : varRow = varRow;
varRow = (row[1] === 'sale_event' && varRow === 0 ) ? varRow = 10 : varRow = varRow;
varRow = (row[1] === 'sale_teacher' && varRow === 0 ) ? varRow = 11 : varRow = varRow;
varRow = (row[1] === 'sale_infrastructure' && varRow === 0 ) ? varRow = 12 : varRow = varRow;
varRow = (row[1] === 'sale_scholarships' && varRow === 0 ) ? varRow = 13 : varRow = varRow;
varRow = (row[1] === 'sale_staff' && varRow === 0 ) ? varRow = 14 : varRow = varRow;
varRow = (row[1] === 'sale_training' && varRow === 0 ) ? varRow = 15 : varRow = varRow;
varRow = (row[1] === 'capex' && varRow === 0 ) ? varRow = 16 : varRow = varRow;

this.setDataAtCell(row[0], varRow, Number(varField) );

}

//statements;
let sale_direct;
let sale_donation;
let sale_external_library;
let sale_event;
let sale_teacher;
Expand All @@ -159,20 +162,21 @@ export class GridComponent implements OnInit, OnDestroy {
let capex;

sale_direct = _.isNil(this.getDataAtCell(row[0],7)) ? sale_direct = 0 : sale_direct = Number(this.getDataAtCell(row[0],7));
sale_external_library = _.isNil(this.getDataAtCell(row[0],8)) ? sale_external_library = 0 : sale_external_library = Number(this.getDataAtCell(row[0],8));
sale_event = _.isNil(this.getDataAtCell(row[0],9)) ? sale_event = 0 : sale_event = Number(this.getDataAtCell(row[0],9));
sale_teacher = _.isNil(this.getDataAtCell(row[0],10)) ? sale_teacher = 0 : sale_teacher = Number(this.getDataAtCell(row[0],10));
sale_infrastructure = _.isNil(this.getDataAtCell(row[0],11)) ? sale_infrastructure = 0 : sale_infrastructure = Number(this.getDataAtCell(row[0],11));
sale_scholarships = _.isNil(this.getDataAtCell(row[0],12)) ? sale_scholarships = 0 : sale_scholarships = Number(this.getDataAtCell(row[0],12));
sale_staff = _.isNil(this.getDataAtCell(row[0],13)) ? sale_staff = 0 : sale_staff = Number(this.getDataAtCell(row[0],13));
sale_training = _.isNil(this.getDataAtCell(row[0],14)) ? sale_training = 0 : sale_training = Number(this.getDataAtCell(row[0],14));
capex = _.isNil(this.getDataAtCell(row[0],15)) ? capex = 0 : capex = Number(this.getDataAtCell(row[0],15));

let total_descount = sale_direct + sale_external_library + sale_event + sale_teacher + sale_infrastructure + sale_scholarships + sale_staff + sale_training + capex;
sale_donation = _.isNil(this.getDataAtCell(row[0],8)) ? sale_donation = 0 : sale_donation = Number(this.getDataAtCell(row[0],8));
sale_external_library = _.isNil(this.getDataAtCell(row[0],9)) ? sale_external_library = 0 : sale_external_library = Number(this.getDataAtCell(row[0],9));
sale_event = _.isNil(this.getDataAtCell(row[0],10)) ? sale_event = 0 : sale_event = Number(this.getDataAtCell(row[0],10));
sale_teacher = _.isNil(this.getDataAtCell(row[0],11)) ? sale_teacher = 0 : sale_teacher = Number(this.getDataAtCell(row[0],11));
sale_infrastructure = _.isNil(this.getDataAtCell(row[0],12)) ? sale_infrastructure = 0 : sale_infrastructure = Number(this.getDataAtCell(row[0],12));
sale_scholarships = _.isNil(this.getDataAtCell(row[0],13)) ? sale_scholarships = 0 : sale_scholarships = Number(this.getDataAtCell(row[0],13));
sale_staff = _.isNil(this.getDataAtCell(row[0],14)) ? sale_staff = 0 : sale_staff = Number(this.getDataAtCell(row[0],14));
sale_training = _.isNil(this.getDataAtCell(row[0],15)) ? sale_training = 0 : sale_training = Number(this.getDataAtCell(row[0],15));
capex = _.isNil(this.getDataAtCell(row[0],16)) ? capex = 0 : capex = Number(this.getDataAtCell(row[0],16));

let total_descount = sale_direct + sale_donation + sale_external_library + sale_event + sale_teacher + sale_infrastructure + sale_scholarships + sale_staff + sale_training + capex;
let total = Number(this.getDataAtCell(row[0],6)) - ( Number(this.getDataAtCell(row[0],6)) * total_descount / 100 );


this.setDataAtCell(row[0], 16, total );
this.setDataAtCell(row[0], 17, total );
break;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import {Component} from '@angular/core';
import {ICellRendererAngularComp} from 'ag-grid-angular';

@Component({
selector: 'child-cell',
template: `
<span><img src="../assets/images/edit.png" (click)="invokeParentMethod()"/></span>
`
})
export class CheckProjectRendererComponent implements ICellRendererAngularComp {
public params: any;

agInit(params: any): void {
this.params = params;
}

public invokeParentMethod() {
this.params.context.componentParent.checkProject(this.params.node);
}

refresh(): boolean {
return false;
}
}
7 changes: 7 additions & 0 deletions src/app/shared/components/project/project.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { Module } from 'ag-grid-community';
import * as _ from 'lodash';
import { selectionRenderComponent } from '../../render/selection-render.component';
import { SelectProjectRendererComponent } from './select-project-renderer.component';
import { CheckProjectRendererComponent } from './check-project-renderer.component';
import { ExcelImportService } from '../../service/import-excel.service';
import { NgxUiLoaderService } from 'ngx-ui-loader';
import { ProformOptionsStateComponent } from 'src/app/ui/proform-state/proform-options-state/proform-options-state.component';
Expand Down Expand Up @@ -48,6 +49,8 @@ export class ProjectComponent implements OnInit {
@Output()
public exportExcel = new EventEmitter<any>();
@Output()
public checkSelected = new EventEmitter<any>();
@Output()
public projectSelected = new EventEmitter<any>();
@Output()
public emitJsonData = new EventEmitter<any>();
Expand All @@ -61,6 +64,7 @@ export class ProjectComponent implements OnInit {
this.context = { componentParent: this };
this.frameworkComponents = {
selectionRender: selectionRenderComponent,
checkProjectRenderer: CheckProjectRendererComponent,
selectProjectRenderer: SelectProjectRendererComponent,
proformOptionsStateRenderer: ProformOptionsStateComponent

Expand All @@ -87,6 +91,9 @@ export class ProjectComponent implements OnInit {
this.projectSelected.emit(row);
}

public checkProject(row) {
this.checkSelected.emit(row);
}

public changeView() {
this.uploadFile = !this.uploadFile;
Expand Down
13 changes: 13 additions & 0 deletions src/app/shared/service/export-excel.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@ export class ExcelExportService {
let row;
const rowBlank = null;
const totalDescount = ( footer['sale_direct'] +
footer['sale_donation'] +
footer['sale_external_library'] +
footer['sale_event'] +
footer['sale_teacher'] +
Expand All @@ -379,6 +380,7 @@ export class ExcelExportService {
dataDetail.push(rowBlank);
dataDetail.push(footer['subtotal'].toFixed(2));
dataDetail.push(footer['sale_direct'].toFixed(2));
dataDetail.push(footer['sale_donation'].toFixed(2));
dataDetail.push(footer['sale_external_library'].toFixed(2));
dataDetail.push(footer['sale_event'].toFixed(2));
dataDetail.push(footer['sale_teacher'].toFixed(2));
Expand Down Expand Up @@ -419,6 +421,17 @@ export class ExcelExportService {
cell.border = {top: {style: 'thin'}, left: {style: 'thin'}, bottom: {style: 'thin'}, right: {style: 'thin'}};
});

dataDetail = [];
dataDetail.push(rowBlank);
dataDetail.push(rowBlank);
dataDetail.push(ProformDetail.SALE_DONATION.name);
dataDetail.push(footer['sale_donation'].toFixed(2));
dataDetail.push( ( footer['sale_donation'] /100 * footer['subtotal'] ).toFixed(2) );
row = worksheet.addRow(dataDetail);
row.eachCell((cell, number) => {
cell.border = {top: {style: 'thin'}, left: {style: 'thin'}, bottom: {style: 'thin'}, right: {style: 'thin'}};
});

dataDetail = [];
dataDetail.push(rowBlank);
dataDetail.push(rowBlank);
Expand Down
10 changes: 8 additions & 2 deletions src/app/shared/shared.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { SelectProjectRendererComponent } from './components/project/select-proj
import { NgxUiLoaderModule } from 'ngx-ui-loader';
import { NgbDropdownModule, NgbModule } from '@ng-bootstrap/ng-bootstrap';
import { ProformOptionsStateComponent } from '../ui/proform-state/proform-options-state/proform-options-state.component';
import { CheckProjectRendererComponent } from './components/project/check-project-renderer.component';

@NgModule({
imports: [
Expand All @@ -25,7 +26,11 @@ import { ProformOptionsStateComponent } from '../ui/proform-state/proform-option
FormsModule,
ReactiveFormsModule,
NgxUiLoaderModule,
AgGridModule.withComponents([selectionRenderComponent, SelectProjectRendererComponent, ProformOptionsStateComponent]),
AgGridModule.withComponents([
selectionRenderComponent,
SelectProjectRendererComponent,
CheckProjectRendererComponent,
ProformOptionsStateComponent]),
HotTableModule.forRoot(),
FormlyModule.forRoot({
types: [
Expand All @@ -47,7 +52,8 @@ import { ProformOptionsStateComponent } from '../ui/proform-state/proform-option
HotableComponent,
FormlyFieldNgbDatePicker,
FormlyFieldNgbTimePicker,
SelectProjectRendererComponent
SelectProjectRendererComponent,
CheckProjectRendererComponent
],
providers: [],
exports: [
Expand Down
Loading

0 comments on commit 0252569

Please sign in to comment.