Skip to content

Commit

Permalink
primeng: admin orders
Browse files Browse the repository at this point in the history
* Removes type, exchange_rate field from the orders.
* Fixes enable Receipts tab after a send order.
* Removes exange_rate from the receipt.
* Reloads files on the file component when the tab panel is selected.
* Removes exange_rate, order_date and receipt_date form the order lines.
* Adds a generic notes component.
* Adds an URL tab parameter to the order detailed view to activate the receipt tab based on the URL.
* Reloads the data for the order lines and receipts on the order detailed view when the tab is selected.
* Removes the continue button on the receipt view.
* Removes receipt and receipt lines detailed view.
* Fixes notes and amount_adjustments on the receipt editor.
* Fixes action button disabled property.

Co-Authored-by: Johnny Mariéthoz <[email protected]>
Co-Authored-by: Pascal Repond <[email protected]>
  • Loading branch information
jma and PascalRepond committed Jan 23, 2025
1 parent a4b2c29 commit 1a658b7
Show file tree
Hide file tree
Showing 50 changed files with 505 additions and 1,522 deletions.
9 changes: 5 additions & 4 deletions projects/admin/src/app/acquisition/acquisition.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import { TranslateService } from '@ngx-translate/core';
import { ApiService, CoreModule, RecordModule } from '@rero/ng-core';
import { SharedModule } from '@rero/shared';
import { PreviewEmailModule } from '../shared/preview-email/preview-email.module';
import { PrimengImportModule } from '../shared/primeng-import/primeng-import.module';
import { AcquisitionRoutingModule } from './acquisition-routing.module';
import { AcqAccountApiService } from './api/acq-account-api.service';
import { AcqOrderApiService } from './api/acq-order-api.service';
Expand All @@ -42,7 +41,6 @@ import { OrderLineComponent } from './components/order/order-detail-view/order-l
import { OrderLinesComponent } from './components/order/order-detail-view/order-lines/order-lines.component';
import { OrderEmailFormComponent } from './components/order/order-email-form/order-email-form.component';
import { OrderSummaryComponent } from './components/order/order-summary/order-summary.component';
import { ReceiptDetailViewComponent } from './components/receipt/receipt-detail-view/receipt-detail-view.component';
import { OrderReceipt } from './components/receipt/receipt-form/order-receipt';
import { OrderReceiptForm } from './components/receipt/receipt-form/order-receipt-form';
import { OrderReceiptViewComponent } from './components/receipt/receipt-form/order-receipt-view.component';
Expand All @@ -59,6 +57,9 @@ import { NoteBadgeColorPipe } from './pipes/note-badge-color.pipe';
import { PreviewContentPipe } from './pipes/preview-content.pipe';
import { ReceiptLineTotalAmountPipe } from './pipes/receipt-line-total-amount.pipe';
import { ReceptionDatesPipe } from './pipes/reception-dates.pipe';
import { ChipsModule } from 'primeng/chips';
import { PrimengImportModule } from '../shared/primeng-import/primeng-import.module';
import { NotesComponent } from './components/notes/notes.component';

@NgModule({
declarations: [
Expand All @@ -82,13 +83,13 @@ import { ReceptionDatesPipe } from './pipes/reception-dates.pipe';
SelectAccountEditorWidgetComponent,
ReceiptListComponent,
ReceiptSummaryComponent,
ReceiptDetailViewComponent,
NoteBadgeColorPipe,
AccountAvailableAmountPipe,
ReceptionDatesPipe,
PreviewContentPipe,
ReceiptLineTotalAmountPipe,
OrderEmailFormComponent
OrderEmailFormComponent,
NotesComponent
],
imports: [
CommonModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import {
AcqOrderHistoryVersionResponseInterface,
AcqOrderLineStatus,
AcqOrderStatus,
AcqOrderType,
IAcqOrder,
IAcqOrderLine
} from '../classes/order';
Expand All @@ -47,7 +46,6 @@ export class AcqOrderApiService extends BaseApi {
/** Default values */
public readonly orderDefaultData = {
priority: 0,
type: AcqOrderType.MONOGRAPH,
status: AcqOrderStatus.PENDING,
notes: []
};
Expand All @@ -58,7 +56,6 @@ export class AcqOrderApiService extends BaseApi {
received_quantity: 0,
amount: 0,
total_amount: 0,
exchange_rate: 0,
notes: []
};

Expand All @@ -79,8 +76,8 @@ export class AcqOrderApiService extends BaseApi {
* @param orderPid: the order pid
* @return: the corresponding AcqOrder
*/
getOrder(orderPid: string): Observable<IAcqOrder> {
return this.recordService.getRecord('acq_orders', orderPid, 0, BaseApi.reroJsonheaders).pipe(
getOrder(orderPid: string, resolve=0): Observable<IAcqOrder> {
return this.recordService.getRecord('acq_orders', orderPid, resolve, BaseApi.reroJsonheaders).pipe(
map(data => ({...this.orderDefaultData, ...data.metadata}) )
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export class AcqReceiptApiService {

/** Default value for an AcqReceipt */
public readonly receiptDefaultData = {
exchange_rate: 0,
amount_adjustments: [],
quantity: 0,
total_amount: 0,
Expand Down
19 changes: 1 addition & 18 deletions projects/admin/src/app/acquisition/classes/order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,6 @@ export enum AcqOrderStatus {
RECEIVED = 'received',
}

/** Enumeration about order type */
export enum AcqOrderType {
MONOGRAPH = 'monograph',
SERIAL = 'serial',
STANDING_ORDER = 'standing_order',
MONOGRAPHIC_SET = 'monographic_set',
PLANNED_ORDER = 'planned_order',
MULTI_VOLUME = 'multi_volume'
}

/** interface to describe an accounting information section for an AcqOrder */
export interface IAcqOrderAccountingInformation {
total_amount: number;
Expand All @@ -57,18 +47,14 @@ export interface IAcqOrderAccountingInformation {
export interface IAcqOrder extends IAcqBaseResource, IAcqResourceWithNotes {
reference: string;
priority: number;
type: AcqOrderType;
status: AcqOrderStatus;
currency: string;
order_date: Date;
account_statement: {
provisional: IAcqOrderAccountingInformation,
expenditure: IAcqOrderAccountingInformation
}
order_lines?: {
order_date: Date,
receipt_date: Date,
}[];
order_lines?: {}[];
vendor: IObjectReference;
is_current_budget: boolean;
}
Expand All @@ -92,9 +78,6 @@ export interface IAcqOrderLine extends IAcqBaseResource, IAcqResourceWithNotes {
amount: number;
discount_amount: number;
total_amount: number;
exchange_rate: number;
order_date: Date;
receipt_date: Date;
acq_account: IObjectReference;
acq_order: IObjectReference;
document: IObjectReference|{
Expand Down
1 change: 0 additions & 1 deletion projects/admin/src/app/acquisition/classes/receipt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export class AcqReceiptAmountAdjustment {
export interface IAcqReceipt extends IAcqBaseResource, IAcqResourceWithNotes {
acq_order: IObjectReference;
reference?: string;
exchange_rate: number;
amount_adjustments: AcqReceiptAmountAdjustment[];
currency?: string;
quantity?: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
-->
<p-dropdown
styleClass="w-full"
class="w-full"
[showClear]="true"
[options]="accountList"
[placeholder]="to.placeholder"
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import { orderAccountsAsTree } from '../../../../utils/account';
@Component({
selector: 'admin-select-account-editor-widget',
templateUrl: './select-account-editor-widget.component.html',
styleUrls: ['../../../../acquisition.scss', './select-account-editor-widget.component.scss'],
changeDetection: ChangeDetectionStrategy.Default,
})
export class SelectAccountEditorWidgetComponent extends FieldType implements OnInit {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<dl class="metadata">
@for (note of notes(); track note) {
<dt>
<p-tag [value]="note.type | translate" [severity]="note | noteBadgeColor" />
</dt>
<dd>
<blockquote
class="p-0 m-0"
[innerHTML]="note.content | nl2br"
></blockquote>
</dd>
}
</dl>
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Component, input } from '@angular/core';

@Component({
selector: 'admin-notes',
templateUrl: './notes.component.html'
})
export class NotesComponent {

notes = input<[{type, content}]>();
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,20 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
@if (order) {
<article class="grid order-brief-view">
<div class="col-9 pl-0">
<h5 class="m-0"><a [routerLink]="[detailUrl.link]">{{ order.reference }}</a></h5>
<article class="grid align-items-top">
<div class="col-9">
<h5><a [routerLink]="[detailUrl.link]">{{ order.reference }}</a></h5>
<ng-container *ngVar="order.notes | notesFilter: [noteType.STAFF_NOTE] as notes">
@if (notes.length > 0) {
<div class="description" [innerHTML]="notes[0].content | nl2br"></div>
<div class="font-italic" [innerHTML]="notes[0].content | nl2br"></div>
}
</ng-container>
<div class="metadata">
<span class="font-bold text-color-secondary text-sm">
[
{{ order.status | translate }}
@switch (order.status) {
@case (orderStatus.ORDERED) {
- {{ orderDate | dateTranslate: 'shortDate' }}
- {{ order.order_date| dateTranslate: 'shortDate' }}
}
@case (orderStatus.RECEIVED) {
- {{ receptionDate | dateTranslate: 'shortDate' }}
Expand All @@ -40,19 +41,20 @@ <h5 class="m-0"><a [routerLink]="[detailUrl.link]">{{ order.reference }}</a></h5
<ng-container *ngVar="order.vendor.pid | getRecord: 'vendors': 'field': 'name' | async as vendor">
- {{ vendor | truncateText : 10 : '…'}}
</ng-container>
</div>
]
</span>
</div>
<div class="col-3 ordinal-infos">
<div class="col-3 flex flex-column gap-1">
@if (displayProvisionalAccountingData) {
<div class="accounting-infos">
<label class="total-amount">{{ order.account_statement.provisional.total_amount | currency : order.currency }}</label>
<span class="counter ordered-counter border-left">{{ order.account_statement.provisional.quantity }}</span>
<div class="flex">
<label class="w-8 text-center surface-border border-1 p-2 surface-100 border-round-left font-bold">{{ order.account_statement.provisional.total_amount | currency : order.currency }}</label>
<span class="w-4 surface-border border-1 p-2 surface-100 border-round-right text-color-secondary text-right"><i class="fa fa-shopping-cart"></i>&nbsp;{{ order.account_statement.provisional.quantity }}</span>
</div>
}
@if (displayExpenditureAccountingData) {
<div class="accounting-infos">
<label class="total-amount">{{ order.account_statement.expenditure.total_amount | currency : order.currency }}</label>
<span class="counter received-counter border-left">{{ order.account_statement.expenditure.quantity }}</span>
<div class="flex">
<label class="w-8 text-center surface-border border-1 p-2 surface-100 border-round-left font-bold">{{ order.account_statement.expenditure.total_amount | currency : order.currency }}</label>
<span class="w-4 surface-border border-1 p-2 surface-100 border-round-right text-color-secondary text-right"><i class="fa fa-sign-in"></i>&nbsp;{{ order.account_statement.expenditure.quantity }}</span>
</div>
}
</div>
Expand Down

This file was deleted.

Loading

0 comments on commit 1a658b7

Please sign in to comment.