All files / source/branches create.js

100% Statements 5/5
100% Branches 2/2
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            3x 3x                                                                                                                                                       2x   1x 1x              
import moment from 'moment-timezone';
 
import APIError from '../../helpers/error';
import BranchDao from '../../database/dao/branch';
 
async function createBranch(branch) {
  try {
    const newBranch = await BranchDao.createBranch({
      code: branch.code,
      name: branch.name,
      restrictSearchSepDoc: branch.restrictSearchSepDoc,
      companyCode: branch.companyCode,
      mandatoryComplementAddress: branch.mandatoryComplementAddress,
      generateInventoryForSeparationDiscrepancy:
        branch.generateInventoryForSeparationDiscrepancy,
      email: branch.email,
      phone: branch.phone,
      cnpj: branch.cnpj,
      stateRegistration: branch.stateRegistration,
      ibge: branch.ibge,
      postalCode: branch.postalCode,
      street: branch.street,
      number: branch.number,
      complement: branch.complement,
      city: branch.city,
      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 || '1,2,3,4',
      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,
      consolidation: branch.consolidation,
      dockControl: branch.dockControl,
      blindConference: branch.blindConference,
      automaticSeparationAfterCuttingCables:
        branch.automaticSeparationAfterCuttingCables,
      automaticCheckAfterPicking: branch.automaticCheckAfterPicking,
      note: branch.note,
      preConference: branch.preConference,
      receiveLeftover: branch.receiveLeftover,
      packageCode: branch.packageCode,
      requestResupplyQuantity: branch.requestResupplyQuantity,
      prioritySuggestResupply: branch.prioritySuggestResupply,
      limitResupplyUser: branch.limitResupplyUser,
      serialControlDeposit: branch.serialControlDeposit,
      prefix: branch.prefix,
      notConfirmProductWaveTransfer: branch.notConfirmProductWaveTransfer,
      automaticReallocation: branch.automaticReallocation,
      dockPrintConsolidation: branch.dockPrintConsolidation,
      autoFinalizeNoDivergence: branch.autoFinalizeNoDivergence,
      createdUser: branch.createdUser,
      productAddressBranchCapacity: branch.productAddressBranchCapacity,
      createdAt: moment().format(),
      updatedUser: branch.updatedUser,
      updatedAt: moment().format(),
      yellowLightValue: branch.yellowLightValue,
      greenLightValue: branch.greenLightValue,
      enableStockMirror: branch.enableStockMirror,
      trackingDashboardActivateSound: branch.trackingDashboardActivateSound,
      trackingDashboardColumnSequence: branch.trackingDashboardColumnSequence,
      trackingDashboardRefreshTime: branch.trackingDashboardRefreshTime
    });
    return newBranch;
  } catch (error) {
    console.log(error);
    throw new APIError('', error);
  }
}
 
export default {
  createBranch,
};