Skip to content

Commit

Permalink
Merge pull request #84 from bcgov/feature/bug-fix-Forage-Inv-Screen
Browse files Browse the repository at this point in the history
Fixed runtime errors on Forage Inv and Grain Sedded/ Unseeded invento…
  • Loading branch information
vivid-esnauffer authored Oct 24, 2024
2 parents 70f4456 + 3908000 commit ed8f0fb
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,8 @@ export class ForageInventoryComponent extends BaseComponent implements OnChanges
fldPlantings.push( self.fb.group(
addPlantingObject(pltg.cropYear, pltg.fieldId, pltg.insurancePlanId, pltg.inventoryFieldGuid,
pltg.lastYearCropCommodityId, pltg.lastYearCropCommodityName, pltg.lastYearCropVarietyId, pltg.lastYearCropVarietyName,
pltg.plantingNumber, pltg.isHiddenOnPrintoutInd,
pltg.inventoryUnseeded, null, new FormArray ([]), pltgInventorySeededForages ) ) )
pltg.plantingNumber, pltg.isHiddenOnPrintoutInd, null,
pltg.inventoryUnseeded, new FormArray ([]), pltgInventorySeededForages ) ) )
}

)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1203,16 +1203,24 @@ onDeleteField(field) {
if ( frmPlanting.value.deletedByUserInd == true ||
areNotEqual(lastYearCropCommodityId, originalPlanting.lastYearCropCommodityId) ||
areNotEqual(lastYearCropVarietyId, originalPlanting.lastYearCropVarietyId) ||
areNotEqual(frmPlanting.value.acresToBeSeeded, originalPlanting.inventoryUnseeded.acresToBeSeeded) ||
areNotEqual(frmPlanting.value.cropCommodityId, originalPlanting.inventoryUnseeded.cropCommodityId) ||
areNotEqual(frmPlanting.value.cropVarietyId, originalPlanting.inventoryUnseeded.cropVarietyId) ||
areNotEqual(frmPlanting.value.isUnseededInsurableInd, originalPlanting.inventoryUnseeded.isUnseededInsurableInd) ||
areNotEqual(frmPlanting.value.isHiddenOnPrintoutInd, originalPlanting.isHiddenOnPrintoutInd)
) {

return true
}

if ( originalPlanting.inventoryUnseeded &&
(frmPlanting.value.deletedByUserInd == true ||
areNotEqual(frmPlanting.value.acresToBeSeeded, originalPlanting.inventoryUnseeded.acresToBeSeeded) ||
areNotEqual(frmPlanting.value.cropCommodityId, originalPlanting.inventoryUnseeded.cropCommodityId) ||
areNotEqual(frmPlanting.value.cropVarietyId, originalPlanting.inventoryUnseeded.cropVarietyId) ||
areNotEqual(frmPlanting.value.isUnseededInsurableInd, originalPlanting.inventoryUnseeded.isUnseededInsurableInd)
)
) {

return true
}


// now check inventory seeded grains
for (let n = 0; n < frmPlanting.value.inventorySeededGrains.controls.length; n++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export interface CropCommodityVarietyOptionsType {

export function addPlantingObject(cropYear, fieldId, insurancePlanId, inventoryFieldGuid, lastYearCropCommodityId,
lastYearCropCommodityName, lastYearCropVarietyId, lastYearCropVarietyName, plantingNumber, isHiddenOnPrintoutInd, underseededInventorySeededForageGuid,
inventoryUnseeded: InventoryUnseeded, inventorySeededGrains: FormArray, inventorySeededForages: FormArray,) {
inventoryUnseeded: InventoryUnseeded, inventorySeededGrains: FormArray, inventorySeededForages: FormArray) {

return {
cropYear: [ cropYear ],
Expand All @@ -44,8 +44,10 @@ export function addPlantingObject(cropYear, fieldId, insurancePlanId, inventoryF
cropCommodityName: [ (inventoryUnseeded && inventoryUnseeded.cropCommodityName) ? inventoryUnseeded.cropCommodityName : CROP_COMMODITY_UNSPECIFIED.NAME ],
cropVarietyId: [ (inventoryUnseeded && inventoryUnseeded.cropVarietyId) ? inventoryUnseeded.cropVarietyId : CROP_COMMODITY_UNSPECIFIED.ID ],
cropVarietyName: [ (inventoryUnseeded && inventoryUnseeded.cropVarietyName) ? inventoryUnseeded.cropVarietyName : CROP_COMMODITY_UNSPECIFIED.NAME ],
cropCommodityVarietyId: [ `${inventoryUnseeded.cropCommodityId||0}_${inventoryUnseeded.cropVarietyId||0}` ],
cropCommodityVarietyName: [ inventoryUnseeded.cropVarietyName ? inventoryUnseeded.cropVarietyName : inventoryUnseeded.cropCommodityName ],
cropCommodityVarietyId: [ `${(inventoryUnseeded && inventoryUnseeded.cropCommodityId)||0}_${(inventoryUnseeded && inventoryUnseeded.cropVarietyId)||0}` ],
cropCommodityVarietyName: [ inventoryUnseeded ?
(inventoryUnseeded.cropVarietyName ? inventoryUnseeded.cropVarietyName : inventoryUnseeded.cropCommodityName)
: '' ],
deletedByUserInd: [ (inventoryUnseeded && inventoryUnseeded.deletedByUserInd) ? inventoryUnseeded.deletedByUserInd : false ],
isUnseededInsurableInd: [ (!inventoryUnseeded || inventoryUnseeded.isUnseededInsurableInd == undefined) ? true : inventoryUnseeded.isUnseededInsurableInd], // defaults to true
isHiddenOnPrintoutInd: [ isHiddenOnPrintoutInd ],
Expand Down

0 comments on commit ed8f0fb

Please sign in to comment.