All files / source/branches update.js

100% Statements 5/5
100% Branches 0/0
100% Functions 1/1
100% Lines 5/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98            3x 3x                                                                                                                                                               2x   1x 1x              
import moment from 'moment-timezone';
 
import APIError from '../../helpers/error';
import BranchDao from '../../database/dao/branch';
 
async function updateBranch(branchId, branch) {
  try {
    const updBranch = await BranchDao.updateBranch(
      {
        id: branchId,
      },
      {
        name: branch.name,
        companyCode: branch.companyCode,
        email: branch.email,
        phone: branch.phone,
        cnpj: branch.cnpj,
        restrictSearchSepDoc: branch.restrictSearchSepDoc,
        stateRegistration: branch.stateRegistration,
        ibge: branch.ibge,
        postalCode: branch.postalCode,
        street: branch.street,
        number: branch.number,
        complement: branch.complement,
        city: branch.city,
        mandatoryComplementAddress: branch.mandatoryComplementAddress,
        district: branch.district,
        state: branch.state,
        country: branch.country,
        limitProductsWave: branch.limitProductsWave,
        requestWeightDimensions: branch.requestWeightDimensions,
        mandatoryWeightDimensions: branch.mandatoryWeightDimensions,
        partialInboundCheck: branch.partialInboundCheck,
        separationMode: branch.separationMode,
        prioritySuggest: branch.prioritySuggest,
        inboundCheckPlate: branch.inboundCheckPlate,
        preReceiptDeposit: branch.preReceiptDeposit,
        inboundDeposit: branch.inboundDeposit,
        resaleDeposit: branch.resaleDeposit,
        inventoryDeposit: branch.inventoryDeposit,
        divergenceDeposit: branch.divergenceDeposit,
        separationDivergenceDeposit: branch.separationDivergenceDeposit,
        damageDeposit: branch.damageDeposit,
        rejectedDeposit: branch.rejectedDeposit,
        qualityDeposit: branch.qualityDeposit,
        spareDeposit: branch.spareDeposit,
        intermediaryDeposit: branch.intermediaryDeposit,
        factoryDeposit: branch.factoryDeposit,
        crossdockingDeposit: branch.crossdockingDeposit,
        branchInInventory: branch.branchInInventory,
        withdrawUser: branch.withdrawUser,
        usesCableCuttingPlan: branch.usesCableCuttingPlan,
        usesCarrierSchedule: branch.usesCarrierSchedule,
        note: branch.note,
        consolidation: branch.consolidation,
        dockControl: branch.dockControl,
        blindConference: branch.blindConference,
        automaticSeparationAfterCuttingCables:
          branch.automaticSeparationAfterCuttingCables,
        automaticCheckAfterPicking: branch.automaticCheckAfterPicking,
        preConference: branch.preConference,
        receiveLeftover: branch.receiveLeftover,
        packageCode: branch.packageCode,
        requestResupplyQuantity: branch.requestResupplyQuantity,
        prioritySuggestResupply: branch.prioritySuggestResupply,
        restrictionPicking: branch.restrictionPicking,
        limitResupplyUser: branch.limitResupplyUser,
        serialControlDeposit: branch.serialControlDeposit,
        prefix: branch.prefix,
        notConfirmProductWaveTransfer: branch.notConfirmProductWaveTransfer,
        automaticReallocation: branch.automaticReallocation,
        dockPrintConsolidation: branch.dockPrintConsolidation,
        generateInventoryForSeparationDiscrepancy:
          branch.generateInventoryForSeparationDiscrepancy,
        autoFinalizeNoDivergence: branch.autoFinalizeNoDivergence,
        updatedUser: branch.updatedUser,
        productAddressBranchCapacity: branch.productAddressBranchCapacity,
        updatedAt: moment().format(),
        yellowLightValue: branch.yellowLightValue,
        greenLightValue: branch.greenLightValue,
        enableStockMirror: branch.enableStockMirror,
        trackingDashboardActivateSound: branch.trackingDashboardActivateSound,
        trackingDashboardColumnSequence: branch.trackingDashboardColumnSequence,
        trackingDashboardRefreshTime: branch.trackingDashboardRefreshTime,
        trackingDashboardOrderTypes: branch.trackingDashboardOrderTypes,
      }
    );
    return updBranch;
  } catch (error) {
    console.log(error);
    throw new APIError('', error);
  }
}
 
export default {
  updateBranch,
};