Skip to content

Commit

Permalink
Tested and fixed transaction patch
Browse files Browse the repository at this point in the history
  • Loading branch information
DrSqua committed Oct 24, 2024
1 parent 9580eb4 commit 5008904
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {TransactionService} from "@ingenium/app/core/services/coreAPI/transactio
import {StaffProductBlueprintService} from "@ingenium/app/core/services/staff/staff-productblueprint-service";
import {ValidityEnum, ValidityList} from "@ingenium/app/shared/models/transaction/validityEnum";
import {PaymentStatusEnum, PaymentStatusList} from "@ingenium/app/shared/models/payment/statusEnum";
import {removeNull} from "@ingenium/app/core/services/serviceUtils";

@Component({
selector: 'app-transaction-detail',
Expand Down Expand Up @@ -75,17 +76,19 @@ export class TransactionDetailComponent implements OnInit {


const interactionPatch = patchUserValue ? {'user': patchUserValue} : null;
let patchObject: {[key: string] : any} = {
const patchObject: {[key: string] : any} = {
validity: patchValidity,
interaction: interactionPatch
};

const patchObjectFiltered = removeNull(patchObject)

// Quick check for none ( more space efficient on DB )
const noteControlValue = this.transactionForm.controls['noteControl'].value;
const noteValue = noteControlValue === '' ? null: noteControlValue;
const patchNote = noteValue !== this.transaction.note;
if (patchNote) {
patchObject['note'] = patchNote
patchObjectFiltered['note'] = noteValue
}

if (patchValidity === null && patchUserValue === null && patchUserValue === this.transaction.note) {
Expand All @@ -96,7 +99,7 @@ export class TransactionDetailComponent implements OnInit {

const forcePatchValue: boolean = this.transactionForm.controls['forcePatchControl'].value;

this.transactionService.patchTransaction(this.transaction.interaction.interaction_id, patchObject, forcePatchValue).subscribe(
this.transactionService.patchTransaction(this.transaction.interaction.interaction_id, patchObjectFiltered, forcePatchValue).subscribe(
(transaction: TransactionI) => {
this.transaction = transaction;
this.successMessage = 'Transaction Patched!';
Expand Down

0 comments on commit 5008904

Please sign in to comment.